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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to