Re: Switching between window controllers in code ?
Re: Switching between window controllers in code ?
- Subject: Re: Switching between window controllers in code ?
- From: Quincey Morris <email@hidden>
- Date: Mon, 20 Aug 2012 21:58:42 -0700
On Aug 20, 2012, at 21:32 , Erik Stainsby <email@hidden> wrote:
> Okay so that is working fine, but isn't that a venal sin in Cocoa programming?
-- You can connect an action directly to any object that implements the action. It doesn't have to be a responder.
-- You could have connected the action to First Responder anyway. The action responder chain includes delegates of windows and the application, even though they're not responders. Window controllers only get a shot at responding to such an action because [if] they're the window's delegate. The app delegate is always in the action responder chain.
-- You could have implemented the action method in *both* the window controllers. It wasn't necessary to implement the method in an object common to both chains. The action would then have gone to whichever window controller's window was in the current responder chain (i.e. whichever window controller's window was active).
Note that there would be a small difference doing it this way -- the menu item would be automatically disabled if neither window was active. By putting the action method in the app delegate, it will always be active, unless you add code to the app delegate's user interface item validation to disable the action conditionally.
_______________________________________________
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