This is limited to hidden items that have a key equivalent assigned to them, although if they don’t, there is probably no harm in enabling this option.
This allows a simple way to build menus in code which can then be used with pop-up buttons or even the main menu of an application.
For creating the main menu, this should be done in an applicationWillFinish: delegate method. If done later, the Open Recent menu will not work.
There is a MBDumpMenu function which will take a menu as argument and output the MBMenu structure required to build the menu in code.
Can be used like this:
NSLog(@"\n%@", MBDumpMenu(NSApp.mainMenu));
Some caveats:
1. If you have alternate items *without key equivalents* then you need to ensure that `.modifierFlags` is set to include the modifier flags of the previous item plus an additional modifier key (the one to press to reveal this item).
2. The code does not know about outlets so check your MainMenu.nib in Xcode to see if you connect any outlets to menu items or submenus. If so, you can do `.ref = &menuItemOutlet` or `.submenuRef = &menuOutlet`. The former will store a pointer to the menu item in `menuItemOutlet` where the latter will store a pointer to the menu item’s submenu (and ensure a submenu gets created for this item, even if there are no submenu items defined).
3. The code will insert `«unknown»` for any unknown target or delegate, you will need to manually update this (but if you forget, it’ll result in a compiler error).