• 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: How to enable menu items for the submenu of NSPopupButton?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to enable menu items for the submenu of NSPopupButton?


  • Subject: Re: How to enable menu items for the submenu of NSPopupButton?
  • From: Ron Fleckner <email@hidden>
  • Date: Fri, 17 Aug 2007 18:25:08 +1000

Message: 17
Date: Fri, 17 Aug 2007 11:57:34 +0800
From: "Chen, Jeff" <email@hidden>
Subject: How to enable menu items for the submenu of NSPopupButton?
To: "email@hidden" <email@hidden>
Cc: "Yu, Min" <email@hidden>, "Gu,	Kevin"
	<email@hidden>
Message-ID: <20070817115734026.00000001652@chnxcs325>
Content-Type: text/plain; charset=gb2312

Hi All,

I've met with a issue about menuitem of sub menu:

I create a NSPopupButton, and I want to add sub menu to the 3rd menu item, but in the added sub menu all menu items are disabled.

My sample code is as following:

NSMenu* menu = [(NSPopUpButton*)ControlPtr menu]; // get the menu of NSPopupButton

NSMenu* subMenu = [[[NSMenu alloc] init] autorelease]; // create sub menu

NSMenuItem * item1 = [[[NSMenuItem alloc] initWithTitle:@"Item1" action:NULL keyEquivalent:@""] autorelease];
[subMenu addItem:item1];

NSMenuItem * item2 = [[[NSMenuItem alloc] initWithTitle:@"Item2" action:NULL keyEquivalent:@""] autorelease];
[subMenu addItem:item2];

NSMenuItem * item3 = [[[NSMenuItem alloc] initWithTitle:@"Item3" action:NULL keyEquivalent:@""] autorelease];
[subMenu addItem:item3];

[[subMenu itemAtIndex:0] setRepresentedObject:@"Item1"];
[[subMenu itemAtIndex:1] setRepresentedObject:@"Item2"];
[[subMenu itemAtIndex:2] setRepresentedObject:@"Item3"];

NSMenuItem * mainItem = [menu itemAtIndex:2];

[mainItem setSubmenu:subMenu];// set sub menu


However, in subMenu, all items(item1, item2, item3) are disabled.

Anyone knows how to resolve such issue?

Best Regards
Jeff Chen

I think you may have forgotten to set the target of each of the items. ie, [item1 setTarget:someObject];


Hope that helps,

Ron
_______________________________________________

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: How to enable menu items for the submenu of NSPopupButton?
      • From: "Chen, Jeff" <email@hidden>
  • Prev by Date: Re: "Esc" doesn't work as a menu item key equivalent
  • Next by Date: RE: How to enable menu items for the submenu of NSPopupButton?
  • Previous by thread: RE: How to enable menu items for the submenu of NSPopupButton?
  • Next by thread: RE: How to enable menu items for the submenu of NSPopupButton?
  • Index(es):
    • Date
    • Thread