• 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: NSPopUpButton submenu's
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPopUpButton submenu's


  • Subject: Re: NSPopUpButton submenu's
  • From: SRD <email@hidden>
  • Date: Mon, 16 Nov 2009 18:43:20 -0600

> Hierarchical menus can be confusing because there are so many layers to keep
> track of: menus, items, etc.  In the code above, log the title of the
> selected item.  Is it what you expect?

I do log the titles and they are not what I expect, for example, the
code below produces the output below that.

- (IBAction) readMenuSelection:(id) sender
{
	NSMenu *projectMenu = [sender menu];
	NSLog(@"projectMenu = %@", projectMenu);

	NSMenuItem *menuItem = [sender selectedItem];
	NSLog(@"menuItem %@", menuItem);
	NSLog(@"hasSubMenu %d", [menuItem hasSubmenu]);

	NSMenu *subMenu = [menuItem submenu];
	NSLog(@"submenu %@", subMenu);

Only the first item is a submenu (create) and the other three (load,
save, save as) are NSMenuItems. So if I run it and select a menu item
underneath the 1st layer's 1st item … here's the output ...

2009-11-16 18:35:01.820 mytest[29588:a0f] projectMenu = <NSMenu: 0x100340330>
	Title: ProjectMenu
	Supermenu: 0x0 (None), autoenable: NO
	Items:     (
        "<NSMenuItem: 0x100340180 >",
        "<NSMenuItem: 0x100340450 Create, submenu: 0x100340570 (Create)>",
        "<NSMenuItem: 0x100340ca0 Load>",
        "<NSMenuItem: 0x1003410a0 >",
        "<NSMenuItem: 0x100341120 Save>",
        "<NSMenuItem: 0x1003411d0 Save As ...>"
    )
2009-11-16 18:35:01.820 mytest[29588:a0f] menuItem <NSMenuItem: 0x100340180 >
2009-11-16 18:35:01.821 mytest[29588:a0f] hasSubMenu 0
2009-11-16 18:35:01.821 mytest[29588:a0f] submenu (null)

What I actually selected was a menu item underneath the 'Create' menu
item (2nd level down), but no where's have I actually been able to get
access to it.
_______________________________________________

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

References: 
 >NSPopUpButton submenu's (From: SRD <email@hidden>)
 >Re: NSPopUpButton submenu's (From: Jerry Krinock <email@hidden>)
 >Re: NSPopUpButton submenu's (From: SRD <email@hidden>)
 >Re: NSPopUpButton submenu's (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Stack-based C++ class to wrap NSAutoreleasePool
  • Next by Date: Re: Accessing FilesOwner fm controller
  • Previous by thread: Re: NSPopUpButton submenu's
  • Next by thread: Stack-based C++ class to wrap NSAutoreleasePool
  • Index(es):
    • Date
    • Thread