How to enable menu items for the submenu of NSPopupButton?
How to enable menu items for the submenu of NSPopupButton?
- Subject: How to enable menu items for the submenu of NSPopupButton?
- From: "Chen, Jeff" <email@hidden>
- Date: Fri, 17 Aug 2007 11:57:34 +0800
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
_______________________________________________
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