• 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: Checking/unchecking a menu item based on responder chain
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking/unchecking a menu item based on responder chain


  • Subject: Re: Checking/unchecking a menu item based on responder chain
  • From: Allan Odgaard <email@hidden>
  • Date: Sat, 8 May 2004 12:04:00 +0200

On 8. May 2004, at 11:00, Glen Low wrote:

Assuming that according to good MVC/GUI/ [insert alphabet soup] practice, I don't want the object to "know" about the menu item, is there a neat way of getting the menu command to check or uncheck when the object gets to be in the responder chain?

What do you mean by check and uncheck? Are you referring to sending setState: with NSOnState and NSOffState?

The item will automatically manage the enabled state based on wether or not there is a target in the responder chain which responds to its action method, and when there is, it will send validateMenuItem: to that target, where the target can respond with NO to disable the item (despite being in the responder chain) and it can also do other things like setting the title of the item or the on/off state (and this method will be sent each time the item is going to be displayed).

If you want disabled items to have the state set to NSOffState, then you could e.g. add a catch-all to the app delegate which would do it (and still respond NO to the validate method) -- but I don't think that's such a good idea, and I don't see the necessity in having disabled items forced to have the state set to NSOffState, on the contrary, disabled items should generally reflect the state they would have, when they were/become enabled.
_______________________________________________
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.


  • Follow-Ups:
    • Re: Checking/unchecking a menu item based on responder chain
      • From: Glen Low <email@hidden>
References: 
 >Checking/unchecking a menu item based on responder chain (From: Glen Low <email@hidden>)

  • Prev by Date: [semi-OT] Apple's Help Viewer: a note to the frustrated
  • Next by Date: Re: Instance Variable access
  • Previous by thread: Checking/unchecking a menu item based on responder chain
  • Next by thread: Re: Checking/unchecking a menu item based on responder chain
  • Index(es):
    • Date
    • Thread