views:

127

answers:

1

I have a text field and a button living in a view inside a menu item. The button submits the string in the text field to a function, and that works fine. However, I've also set the button's key equivalent to "return." The key command isn't being picked up, probably because the menu is not the "key" window.

I know how to make a window the key window (makeKeyAndOrderFront) -- what's the equivalent for a view living in a menu?

A: 

Looks like the best way to do this is to ignore the button and tie the NSTextField's built-in return key handling to the desired action:

http://stackoverflow.com/questions/995758/execute-an-action-when-the-enter-key-is-pressed-in-a-nstextfield

Seems to work great.

iconmaster
Yup, that's about what I was going to answer when I got distracted by something else that could potentially solve my problem. Keyboard behavior with a menu displayed is quite tricky because the menu itself intercepts most key equivalents for navigation.
Nicholas Riley