Re: Wiring up MainMenu.xib
Re: Wiring up MainMenu.xib
- Subject: Re: Wiring up MainMenu.xib
- From: Luther Baker <email@hidden>
- Date: Sun, 19 Oct 2014 19:53:08 -0500
> On Oct 19, 2014, at 7:20 PM, Graham Cox <email@hidden> wrote:
...
> Maybe you're joking, but, well, that's not a "trick". It's a key part of Cocoa design.
Good catch. I called it a "trick" as it surprised me that it worked as such. Indeed, I did not really understand why it worked nor how my IBActions were showing up as actions on the first responder. What you're saying makes great sense and motivates the rationale nicely.
Coming from iOS I've not had great occasion to pay much, if any, to first responders in Xibs. Thanks very much for following up and expanding on the concept in layman's terms - even after the original question was answered.
-Luther
> 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