> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to