Cocoa handling of keydown events

I assign certain functions to Command key shortcuts that don’t exist in a menu. I check for these shortcuts in the window keydown event handler. Works fine in Carbon. But in Cocoa I’ve found that it works differently between controls. Listboxes will pass the unhandled keydown to the window. But TextAreas do not – unhandled keypresses (e.g. Command-L) die there. I work around this by having the window and the textarea both call a “handlekeydown” method that checks to see if the key pressed is actually a shortcut.

Is this intended behavior for Cocoa TextAreas? If not I’ll report in Feedback with a simple example.

This is about half intentional. We let the Cocoa view have a stab at handling it after we fire the control’s KeyDown event. If the view didn’t handle it, it’ll forward the event up the responder chain and eventually it’ll hit the window and you’ll get the KeyDown event there.

It’s definitely a change from the Carbon behavior and it probably could be changed to be a closer match.

Thanks for the explanation. I never see it get to the window. I’ll file this in Feedback as an inconsistency between Carbon and Cocoa.