Re: Enabling NSMenuItem in Code?
Re: Enabling NSMenuItem in Code?
- Subject: Re: Enabling NSMenuItem in Code?
- From: Sherm Pendley <email@hidden>
- Date: Tue, 20 Apr 2004 22:34:48 -0400
On Apr 20, 2004, at 10:02 PM, Jeffrey J Barbose wrote:
the target should implement validateMenuItem: as well. its return
value sets enabled or not.
You don't have to. The default returns TRUE if the target responds to
the selector specified in the action. This is good enough for many
situations.
You're right though, that if you want to specify more detailed
validation, a custom validateMenuItem: is the way to go. For example,
if you're doing a graphics app and the current selection is an ellipse,
then menu items related to text attributes aren't applicable, so you
might want to disable them.
Also - there's no need to explicitly set a target object. You can pass
nil to setTarget:, and if I recall correctly you can skip calling
setTarget: entirely with the same effect. When the target is nil,
action messages are sent to the responder chain.
See
<
http://developer.apple.com/documentation/Cocoa/Conceptual/
BasicEventHandling/index.html>
sherm--
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.