Re: cancelOperation: does not work for trapping the escape key
Re: cancelOperation: does not work for trapping the escape key
- Subject: Re: cancelOperation: does not work for trapping the escape key
- From: Kenny Leung <email@hidden>
- Date: Tue, 18 Dec 2007 10:12:54 -0800
I just tried overriding performKeyEquivalent: in my window
controller, and no dice. According to the documentation for
cancelOperation: it should not affect anything:
This method is bound to the Escape and Command-. (period) keys. The
key window first searches the view hierarchy for a view whose key
equivalent is Escape or Command-., whichever was entered.
There are no views in my window except for the content view, so
nothing will catch it via the key equivalent.
If none of these views handles the key equivalent, the window sends
a default action message of cancelOperation: to the first responder
The first responder is the window in this case (I think).
and from there the message travels up the responder chain.
up to the window controller.
The fact that keyDown: gets called for other keys makes me think that
the first responder is the window, and that the responder chain is
what I think it is...
-Kenny
On Dec 18, 2007, at 9:54 AM, Jean-Daniel Dupas wrote:
Le 18 déc. 07 à 18:41, Kenny Leung a écrit :
Sorry, I was not clear. My class is a window controller, which
means that it is in the responder chain after the window itself.
It is successfully getting keyDown: events for other keys, but
nothing gets called for the escape key. Just in case, I overrode
acceptsFirstResponder to return YES, but no dice.
You can see a small example at http://www.hexdreams.com/temp/
CancelOperationTest.zip that illustrates my point.
-Kenny
I think the - (BOOL)performKeyEquivalent:(NSEvent *)theEvent method
catch your escape event before it reach the keyDown: method.
If performKeyEquivalent return YES, the keyDown: method will no be
call.
You can find a very good graph fo the event flow here:
http://developer.apple.com/documentation/Cocoa/Conceptual/
EventOverview/EventArchitecture/chapter_2_section_3.html#//
apple_ref/doc/uid/10000060i-CH3-SW10
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden