NSMenuItem Key Equivalents, keyDown events, and system beeps
NSMenuItem Key Equivalents, keyDown events, and system beeps
- Subject: NSMenuItem Key Equivalents, keyDown events, and system beeps
- From: John Rieffel <email@hidden>
- Date: Sun, 18 Apr 2004 13:17:00 -0400
In my application, I have subclassed NSWindow in order to intercept
keyDown events in the main application. As it should, my subclassed keyDown method sends [super keyDown:theEvent] when it isn't interested in the key.
My mystery is this: I have several menu items with key equivalents.
When those keys are pressed, the menu item's action occurs as it should,
but it is accompanied by an alert beep, as if an unbound key had been
pressed. When the menu item is selected by mouse, the action occurs,
this time without an alert beep. The alert beep, therefore, only
happens when the application's main window recieves a keydown event and
passes it to NSWindow.
Why is NSWindow beeping before sending the key equivalent to the menu?
I know from reading the "Basic Event Handling" documentation that
"If no view object in the key window accepts the key event, NSWindows keyDown: attempts to handle the key event itself. It tries to interpret the key event as each of the following, in order, beeping if it fails to match any of them to let the user know the typing couldnt be processed:"
And yet, obviously, one of my views (the NSMenuItem with that key
equivalent) _does_ accept the key equivalent - because the action
corresoping to that NSMenuItem occurs - so why the beep?
Interestingly, if I _don't_ subclass make my application's main window,
then then everything behaves normally, and no beep occurs. The cause of
the my beeps, therefore, must arise from my call to [super
keyDown:theEvent]. But isn't this the proper responder chain sequence?
Thanks,
John Rieffel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.