Search code examples
cocoainterface-builderkeyboard-shortcuts

How to make a keyboard shortcut to close dialog with Xcode/Interface Builder?


This seems awfully basic but here goes. If you are keyboard-oriented you get used to using Command-W to close windows all the time in OS X. I'd like to add that capability to the dialogs I am creating in Interface Builder for my program. I can see how to add a keyboard equivalent to a button action but what if I don't have a button?

Should I add an invisible button and put the shortcut on that? Seems clunky. Surely there is just some method I can override but what I've tried so far isn't working.


Solution

  • Adding an invisible button works just fine.