Jens –

I've been wanting to do similar key handling in my controller class (rather than view classes), so I'm glad I'm not the only one not fully grokking the responder chain. I got some helpful responses to my more specific question, but without loss of generality. Especially: http://www.cocoabuilder.com/archive/message/cocoa/2008/7/9/212381

My takeaway from that experience was that if I need custom event responding, I need my own NSResponder inserted somewhere in the chain. It makes sense, but coming from the other direction ("I want to handle some events in my controller") it's tempting to look for another way that doesn't seem to exist.

hth,
-natevw


On Jul 19, 2008, at 12:34 PM, Jens Alfke wrote:

On 19 Jul '08, at 8:52 AM, Matt Neuburg wrote:

Try it and see. Let's say we want to catch Esc directed to the window as a whole (to exit full screen mode, if I recall your example). So what I would do is to insert an NSResponder instance behind the window in the chain and
implement keyDown:.

I had already tried implementing keyDown: in my controller object, which is the window's delegate, to no avail. But that class is just a direct subclass of NSObject, not NSResponder or NSWindowController. I tried changing its superclass to NSResponder, but that didn't help.

Looks like I need to read up on the conceptual docs about the responder chain, to figure out how to make my object the window's next responder. (I've never manipulated the chain directly before.)

When an event arrives (arrives! It got here by being
handed up thru all the views and the window, which therefore clearly didn't handle it), we look to see if it's for us - i.e., is it Esc or not. If it is, we tell the window to do what it's supposed to do, and the event is not handed any further up the responder chain. If not, we pass the event to super and the event is handed on up the responder chain in the usual way,

That makes sense. I had been thinking that event handlers would need a boolean return value to indicate whether or not they handled the event, but I'd overlooked the behavior of calling super to pass the event up. Thanks!

—Jens_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/nate-lists%40calftrail.com

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to