Re: Responder-Chain question.
Re: Responder-Chain question.
- Subject: Re: Responder-Chain question.
- From: Matt Neuburg <email@hidden>
- Date: Tue, 13 Sep 2011 10:11:03 -0700
On Tue, 13 Sep 2011 15:01:31 +0300, Motti Shneor <email@hidden> said:
>
>I need to insert some controllers I have into the responder chain, in such a place that their functionality (IBActions and menu validation) will be available regardless of specific view focus, etc.
I do this sort of thing all the time, typically at the level just above the window:
id nr = [window nextResponder];
[window setNextResponder:myResponder];
[myResponder setNextResponder: nr];
(Last line perhaps otiose but better safe than sorry.)
Here's another example, where the goal is to do menu item validation / response in a table view:
NSResponder* r = [[myTableView enclosingScrollView] nextResponder];
[[myTableView enclosingScrollView] setNextResponder: self];
[self setNextResponder: r];
Typical use case is that I want to handle key events (e.g. flagsChanged:, keydown:) and/or deal with menus. I've been doing this for years and nothing bad has happened. m.
--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________
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