BR: juce::SystemTrayIconComponent::showDropdownMen () doesn't appear to work

BR: juce::SystemTrayIconComponent::showDropdownMen () doesn’t appear to work

NSMenu* createNSMenu (const PopupMenu& menu, const String& name, int topLevelMenuId, int topLevelIndex, bool addDelegate)
{
    juce_initialiseMacMainMenu();

    if (auto* mm = JuceMainMenuHandler::instance)
        return mm->createMenu (menu, name, topLevelMenuId, topLevelIndex, addDelegate);

    jassertfalse; // calling this before making sure the OSX main menu stuff was initialised?
    return nil;
}

I’m hitting the assert before the return nil, menu stuff not initialised? But it is initialised 4 lines up?

Don’t know if you’ve got a solution just yet, or just for anyone else having this problem.

In order for the native JUCE Mac stuff to initialize correctly, you seem to have to call MenuBarModel::setMacMainMenu somewhere in your app prior to showing the menu (you’ll need to implement some virtual functions of MenuBarModel as well).

2 Likes