• 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: Why does my menu have mutually exclusive states?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does my menu have mutually exclusive states?


  • Subject: Re: Why does my menu have mutually exclusive states?
  • From: Peter Ammon <email@hidden>
  • Date: Fri, 15 Jan 2010 11:50:37 -0800

On Jan 15, 2010, at 11:41 AM, Eric Gorr wrote:

> I have some sample code at:
>
> http://ericgorr.net/cocoadev/UtilityMenu.zip
>
> According to the documentation in "Application Menu and Pop-up List Programming Topics for Cocoa", to get mutually exclusive states, one my manage this oneself:
>
>
>
> You can use states to implement a group of mutually exclusive menu items, much like a group of radio buttons. For example, a game could have three menu items to show the level of play: Beginner, Intermediate, and Advanced. To implement a such a group, create one action message that they all use. This action message changes the appropriate setting, and then reflects that change by unchecking the currently checked item and checking the newly selected item.
> In an action method that responds to all commands in the group use setState: to uncheck the menu item that is currently marked:
> [curItem setState:NSOffState];
> Then mark the newly selected command:
> [sender setState:NSOnState];
>
>
>
> However, when my menu item is selected, I just turn it's state on and do nothing else (for now).
>
> Why is the state of the previously selected items being set to off?

Hi Eric,

Your menu is in an NSPopUpButtonCell, and by default popups set the state of the selected item, and clear the state of other items.  You can disable this behavior by calling [cell setAltersStateOfSelectedItem:NO] on the popup button cell.

-Peter


_______________________________________________

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

  • Follow-Ups:
    • Re: Why does my menu have mutually exclusive states?
      • From: Eric Gorr <email@hidden>
References: 
 >Why does my menu have mutually exclusive states? (From: Eric Gorr <email@hidden>)

  • Prev by Date: Why does my menu have mutually exclusive states?
  • Next by Date: Re: Core Video CIFilters/ playback / compression suggestions?
  • Previous by thread: Why does my menu have mutually exclusive states?
  • Next by thread: Re: Why does my menu have mutually exclusive states?
  • Index(es):
    • Date
    • Thread