Hi
4 years later, I am having the exact same issue as point number 2 above. I want the menu of my SystemTrayIcon to be “macOS” like, i.e. same as other apps. I believe using the SystemTrayIconComponent::showDropdownMenu()
is the way to do this, but there are no examples using it.
Taking the DemoRunner example and changing these lines in Main.cpp at line 70:
m.addItem (1, "Quit");
m.showMenuAsync (PopupMenu::Options(),
ModalCallbackFunction::forComponent (menuInvocationCallback, this));
changed to
m.addItem ("Quit", DemoTaskbarComponent::menuInvocationCallback);
showDropdownMenu(m);
// and I removed the parameters of menuInvocationCallback()
This hits the jassertfalse in createNSMenu()
, line 845 of juce_MainMenu_mac.mm.
Looking at the JUCE code, it seems the JuceMainMenuHandler
singleton is never instanciated, except in MenuBarModel::setMacMainMenu()
, which I guess I should call somehow?
I am not sure I fully grasp what a MenuBarModel is and why it would be nedded for the SystemTrayIcon menu? Could someone point me to the right direction?
Thank you!
Simon
PS: not sure if this is fully related, but there was a similar issue in the past: SystemTrayIconComponent OSX native menus broken in 5.00 working in 4.3.1 ?