Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display selected sub-menuItem in NSPopUpButton

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?

like image 819
Leonardo Avatar asked Oct 20 '22 14:10

Leonardo


1 Answers

The Human Interface Guidelines state:

Avoid adding a submenu to an item in a pop-up menu. A submenu tends to hide choices too deeply and can be physically difficult for users to use.

I assume that since the practice is discouraged (albeit not that strongly) that it is not supported either. I can see how submenus would break some of NSPopUpButton's functionality, all of the item index related methods would not make sense. Those methods would have to use NSIndexPaths instead of simple indexes.

A potential substitute would be to use different indention levels in the menu to indicate hierarchy. I am about to try that myself.

like image 79
harrisg Avatar answered Dec 10 '22 10:12

harrisg