Re: Getting a reference to an NSMenuItem from another nib?
Re: Getting a reference to an NSMenuItem from another nib?
- Subject: Re: Getting a reference to an NSMenuItem from another nib?
- From: mmalcolm crawford <email@hidden>
- Date: Tue, 14 Jun 2005 07:30:22 -0700
On Jun 14, 2005, at 7:13 AM, Sherm Pendley wrote:
You're missing the bigger picture.
You're going to need to make these calls whenever anything that
determines a menu's state would change. Changing the current
selection? Update the relevant menu items. Switching documents?
Update menu items. Etc.
You wind up with setEnabled: calls scattered throughout your code.
Worse, they're called every time the state of your model changes,
instead of only when needed to display a particular menu item.
NSMenuValidation keeps all of your menu validation code in a single
method that's only called when it's needed. You know exactly where
to look if you need to make changes, so it's easy to maintain.
Most importantly, the validateMenuItem: message is only sent to an
object if that object is in the responder chain and it implements the
action associated with the menu item.
Consider a "Copy" menu item. There may be many ways in which a user
can select an item in the user interface and make a copy. If you
consolidate all your menu validation code into a single app
controller, how will you determine whether or not the copy menu item
should be enabled? Rather than the locus of control being in the
object best able to make that decision (the one implementing the
relevant action method), your app controller must now determine what
is the current focus, what possible actions there are, whether they
are valid and so on. Which is likely to translate into a large if/
then table...
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden