Add items app section in native menu


#1

Is there a way I can add items to the section right next to the apple menu, the one that has the ‘Hide Others’ and ‘Quit App’ entries?


#2

You have to create the PopupMenu before calling MenuBarModel::setMacMainMenu just like this:

PopupMenu extra_menu;
extra_menu.addItem (kShowAbout, T("About Your App"));
extra_menu.addSeparator();
extra_menu.addCommandItem(mApplicationCommandManager, kShowAudioPreferences, T("Preferences..."));
MenuBarModel::setMacMainMenu (this, &extra_menu);

I uses the addCommandItem combined with an ApplicationCommandManager to add shortcut to the Preferences item (“cmd + ,” like standard Mac OS app).

Cheers,
Kevin


#3

awesome. That worked. Thank you.


#4

How is this done in the Juce 2.0?

I tried this from my application’s initialization routine:

#if JUCE_MAC
PopupMenu pop;
pop.addItem(123, “Preferences…”);
MenuBarModel::setMacMainMenu(MenuBarModel::getMacMainMenu(), &pop);
#endif

Nothing appears in the Apple (application) menu.


#5

Yeah, it does work. I just checked by inserting that code in the introjucer, and it works just fine.


#6

Then there’s something a-miss with my application, which was generated from Introjucer. I’ve barely modified it.


#7

I ended up having to make my own MenuBarModel instead of using MenuBarModel::getMacMainMenu()


#8

Same here, only working with a custom MenuBarModel.