Thank you Keary. In the meantime I dismissed that NSPopUpButton and put a simple button + a NSTextField aside. They look as a group. When I click on the button I create on the fly a NSPopUpButtonCell and pop it up with performClickWithFrame: Then when the user selects a menu item, the menu item invokes its target-action and I get the menuItem tag and title then I put that title within the NSTextField. I release the NSPopUpButtonCell. Done.
The thing I have still to do is: when the user pops up the menu, I should select and display the latest selected menuItem, opening all of its parents' menu. And I don't know how to do that. Do you have an idea? The purpose is: I have a short hierarchical tree of objects, and the user should be able to choose an object quickly, without opening other panels. Regards -- Leonardo > Da: Keary Suska <cocoa-...@esoteritech.com> > Data: Fri, 14 Feb 2014 08:29:08 -0700 > A: Leonardo <mac.iphone....@gmail.com>, "Cocoa-Dev (Apple)" > <cocoa-dev@lists.apple.com> > Oggetto: Re: Display selectd sub-menuItem in NSPopUpButton > > On Feb 14, 2014, at 5:02 AM, Leonardo wrote: > >> I have filled my NSPopUpButton with menu and submenus. >> >> When I select a menuItem on the root menu (so, not a sub-menuItem), it >> propery displays the menuItem selected. And when I re-click on the popUp >> button, I get the selected menuItem under the mouse. >> >> But if I select a sub-menuItem, it doesn't display it. And if I re-click on >> the popUp button, I don't get it under the mouse. Any time I click on the >> button, I have to look for the selected item diving in the menu hierarchy. >> >> Any solution? > > I basic problem is that NSPopupButton does not support submenus. You can get > the submenu item title to appear when the menu is dismissed but the side > effect is that the item will be added to the top menu. I didn't go any further > with that approach. It is too bad, because I would argue that there are good > use cases for hierarchical menus in popup buttons. > > I don't have any real solutions, however, although I can suggest that you > could "hide" the side effect with a "recents" section of the menu. Otherwise > you will have to subclass NSPopupButtonCell and take over title and menu > handling, AFAICT. > > HTH, > > Keary Suska > Esoteritech, Inc. > "Demystifying technology for your home or business" > _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com