Re: Validating MenuItems before adding them to the menu
Re: Validating MenuItems before adding them to the menu
- Subject: Re: Validating MenuItems before adding them to the menu
- From: Mudi Dandan <email@hidden>
- Date: Tue, 23 Sep 2008 19:45:56 +0200
Thanks Erik, that exactly is I was looking for.
Regarding your recommendation as I learned context menus should not
contain disabled items (check Finder for example) but I'm not really
sure if this mentioned in the HIG.
Mudi
On Sep 23, 2008, at 7:28 PM, Erik Buck wrote:
See the - (id)targetForAction:(SEL)aSelector method. When adding
context menu items, if the target for the menu item's action would
be nil, just don't add the menu item.
However, I recommend adding all menu items that are ever available
and just disabling the ones that aren't currently available. Doing
that will preserve user's muscle memories about where each item is
in the list. Plus, it will let users know what items are sometimes
available even if they are not currently available.
For more options, see
targetForAction:to:from:
Finds an object that can receive the message specified by the given
selector.
- (id)targetForAction:(SEL)anAction to:(id)aTarget from:(id)sender
Discussion
If anAction is NULL, nil is returned. If aTarget is nil, NSApp looks
for an object that can respond to the message—that is, an object
that implements a method matching anAction. If aTarget is not nil,
aTarget is returned. The search begins with the first responder of
the key window. If the first responder does not handle the message,
it tries the first responder’s next responder and continues
following next responder links up the responder chain. If none of
the objects in the key window’s responder chain can handle the
message, NSApp asks the key window’s delegate whether it can handle
the message.
If the delegate cannot handle the message and the main window is
different from the key window, NSApp begins searching again with the
first responder in the main window. If objects in the main window
cannot handle the message, NSApp tries the main window’s delegate.
If it cannot handle the message, NSApp asks itself. If NSApp doesn’t
handle the message, it asks the application delegate. If there is no
object capable of handling the message, nil is returned.
_______________________________________________
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
_______________________________________________
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