I’m trying to find a way to enable/refresh hidden items in my popup menu that are triggered via the ‘alt’ key.
I’ve got a timer running that checks the desktop main mouse source’s modifiers.
if ‘alt’ is pressed, it refreshes the MenuBarComponent.
It works pretty well if I hold down ‘alt’ BEFORE opening the popup menu in the menu bar.
But if a menu is already open, it has no effect. Any ideas on how to get these hidden menu choices to appear after the menu has already appeared? A common example is when you open the Window menu for any app on OS X, and when you press ‘Alt’, the Minimize/Zoom choices changes:
edit:
ah, it doesn’t work if the menu is open, because this doesn’t refresh the menu if the menu names don’t change:
@ed95@t0m i’m still waiting to get some kind of reply on this Pull Request. I have demonstrated the reason it is needed in the first post and demonstrated how I accomplished it in the 3rd post. Hopefully that provides enough context for why this getter is needed.
I’ve replied in the following post, but perhaps it was buried in the thread:
We’d rather not expose the internals of classes like MenuBarModel for the reasons stated in that post. Doing this properly requires some thought and, with the release of JUCE 6 approaching, there’s no bandwidth on the team to look into it right now. If you can propose a PR which achieves what you want without exposing implementation details like this then we’d happily take a look and perhaps merge it but we won’t accept it as it is - I’ll close the PR on GitHub.
I came up with an MVP myself. It wasn’t actually that difficult after all. This is a MVP and should be treated as such
How this works
Setting a menu item to alternate will hide the previous once when holding down option. Therefore, normal and alternate items need to alternating in the PopupMenu you pass to the menu bar. Not sure what happens when you have multiple alternate items in a row
Alternate items need to contain a key combination that include the option/alt key. This is problematic when you enable user defined key commands using the command manager. My code automatically adds the option modifier when the item does not have a key command attached to it.