I need to be able to dynamically change the NSMenu hierarchy every time it is displayed (add / remove items, etc.). For instance:
- the user starts a tracking session in the main menu and selects a submenu
- detecting a submenu is about to open and run code to change it
- track user tracks in the same submenu again: goto 2
So, for this I have an object implementing the NSMenuDelegate protocol. The menuNeedsUpdate method works the first time (2), but does not work the second time a submenu opens. (Called only once per tracking session)
The menuWillOpen method is called every time, but has the following docs warning, which appears to be disqualified using this approach:
Do not change the structure of menus or menu items during this method.
Is there any way to do this?
objective-c cocoa nsmenu nsmenuitem
Chris
source share