I followed the example of the jucer demo for setting up the menubar. I can compile without errors and I see the menubar in my vst plugin with the new column names, but the pop up menu is not working. Not sure if the problem is related to the missing DocumentWindow or something I'm missing in my code.
Here is what I have so far:
ApplicationCommandManager commandManager;
enum Commands{ command1 = 0, command2 };
StringArray SessionComponent::getMenuBarNames() { const char* const names[] = { "example", "settings", nullptr }; return StringArray (names); } PopupMenu SessionComponent::getMenuForIndex (int menuIndex, const String& /*menuName*/) { ApplicationCommandManager *commandManager= &(session->commandManager); PopupMenu menu; if (menuIndex == 0) { menu.addCommandItem (commandManager, command1); menu.addSeparator(); menu.addCommandItem (commandManager, command2); menu.addSeparator(); } else if (menuIndex == 1) { menu.addCommandItem (commandManager, command1); menu.addSeparator(); menu.addCommandItem (commandManager, command2); } return menu; } ApplicationCommandTarget* SessionComponent::getNextCommandTarget() { // this will return the next parent component that is an ApplicationCommandTarget (in this // case, there probably isn't one, but it's best to use this method in your own apps). return findFirstTargetParentComponent(); } void SessionComponent::getAllCommands (Array <CommandID>& commands) { // this returns the set of all commands that this target can perform.. const CommandID ids[] = { command1, command2 }; commands.addArray (ids, numElementsInArray (ids)); } // This method is used when something needs to find out the details about one of the commands // that this object can perform.. void SessionComponent::getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) { const String generalCategory ("General"); const String demosCategory ("Demos"); switch (commandID) { case command1: result.setInfo ("Graphics Rendering", "Shows the graphics demo", demosCategory, 0); //result.setTicked (currentDemoId == command1); result.addDefaultKeypress ('1', ModifierKeys::commandModifier); break; case command2: result.setInfo ("Fonts and Text", "Shows the fonts & text demo", demosCategory, 0); //result.setTicked (currentDemoId == showFontsAndText); result.addDefaultKeypress ('2', ModifierKeys::commandModifier); break; default: break; }; } // this is the ApplicationCommandTarget method that is used to actually perform one of our commands.. bool SessionComponent::perform (const InvocationInfo& info) { switch (info.commandID) { case command1: break; case command2: break; default: return false; }; return true; }
Thanks!