Re: Wiring up MainMenu.xib
Re: Wiring up MainMenu.xib
- Subject: Re: Wiring up MainMenu.xib
- From: Graham Cox <email@hidden>
- Date: Mon, 20 Oct 2014 11:20:07 +1100
On 20 Oct 2014, at 1:51 am, Luther Baker <email@hidden> wrote:
> I see ... the old First Responder Proxy trick :-)
Maybe you're joking, but, well, that's not a "trick". It's a key part of Cocoa design.
If you have an app where the responder changes dynamically - which is usually the case - wiring a menu action to First Responder means that the menu is only available when the object that can respond to it is actually First Responder, or part of the responder chain behind it. Any other time, it's greyed out for you. This is simple and elegant and actually about the only really practical way to do things - consider how you could wire a menu action that applied to a particular kind of view in a multi-document interface where there could be any number of such views but only one active at a time. It quickly becomes a horrible nightmare if there would have to be a single, definite object to which all actions are sent (e.g. app delegate). You'd end up solving that problem by implementing a responder chain maintained by the app and directing actions up through that chain. Luckily, that's exactly how it works already.
Note that all app frameworks since MacApp 1.0 (TCL, Powerplant as well) have all worked in the same way, so it's obviously a good pattern for this problem.
--Graham
_______________________________________________
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