I’m trying to add a simple menu bar to my juce app following juce demo, but it’s not showing? Did the following
class HelloWorldContentComponent : public Component,
public MenuBarModel
.
.
ect
Then all the required pure virtuals
getMenuBarNames()
const PopupMenu getMenuForIndex(int menuIndex, const String&menuName)
menuItemSelected(int menuItemID,int topLevelMenuIndex)
The problem is no menu system comes up, what’s missing? Thanks…
You need to add something like this in your class constructor :
#if JUCE_MAC
setMacMainMenu (this);
#else
setMenuBar (this, 20);
#endif
The conditional is here to use a true system menu on Mac. Whithout it (ie doing only setMenuBar (this, 20)) then there is an extra menu attached to the main window, something that we don’t see ususally in a mac app
Hope this helps
Robert
cheers rbocquier! It’s showing now.
I found that I needed to clear the MacMainMenu in my destructor to avoid a crash.
MenuComponent::~MenuComponent() {
#if JUCE_MAC
setMacMainMenu(nullptr); // avoid jassert
#endif
}