• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Enabling NSMenuItem in Code?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Enabling NSMenuItem in Code? (From: "David Piasecki" <email@hidden>)
 >Re: Enabling NSMenuItem in Code? (From: Jeffrey J Barbose <email@hidden>)

  • Prev by Date: Re: Crash in setTextColor
  • Next by Date: Re: Cocoa Help problems
  • Previous by thread: Re: Enabling NSMenuItem in Code?
  • Next by thread: [Solved] Application Icon
  • Index(es):
    • Date
    • Thread