• 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: A problem with PopupButtonCell --- submenu selection not available
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A problem with PopupButtonCell --- submenu selection not available


  • Subject: Re: A problem with PopupButtonCell --- submenu selection not available
  • From: Graham Cox <email@hidden>
  • Date: Mon, 5 Jul 2010 22:24:08 +1000

On 05/07/2010, at 9:32 PM, Motti Shneor wrote:

> resultIndex = [popUpButtonCell indexOfSelectedItem]; returns -1 (unknown)
> result = [popUpButtonCell selectedItem]; returns nil!
>
> How can I resolve this thing? I MUST have popup menus with sub-menus! Is there a hidden member or method that will tell me what was the last selected menu item?


The pop-up menu control doesn't really work with submenus, but if you bypass the control and just get each menu item to send an action to a target directly, you can do it that way, since the control doesn't actually care that there are submenus, it just doesn't deal with them (and for a pulldown, it doesn't matter as the button's displayed title doesn't change with the menu selection).

This can also work well if the menu has a delegate that populates the menu items, since there's a way to set each menu item's target/action as necessary without too much bother (doing that for a complex menu in IB is very tedious).

Another option is to forget using NSPopUpButtonCell and just write your own view that implements the button part, and show the menu using + [NSMenu (void)popUpContextMenu:(NSMenu *)menu withEvent:(NSEvent *)event forView:(NSView *)view];

--Graham




_______________________________________________

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: A problem with PopupButtonCell --- submenu selection not available
      • From: Motti Shneor <email@hidden>
References: 
 >A problem with PopupButtonCell --- submenu selection not available (From: Motti Shneor <email@hidden>)

  • Prev by Date: Run application before Login starts?
  • Next by Date: GKSession and WLAN
  • Previous by thread: Re: A problem with PopupButtonCell --- submenu selection not available
  • Next by thread: Re: A problem with PopupButtonCell --- submenu selection not available
  • Index(es):
    • Date
    • Thread