hey guys, really struggling with a ApplicationCommandManager and BarMenuModel situation,
where my items do not get displayed within the popupmenu. I can’t see what i’m missing and have been looking at this code for hours.
Here is the code for the BarMenuModel and the ApplicationCommandManager subclass:
BurgerMenu::BurgerMenu()
{
setColour(PopupMenu::backgroundColourId, Colours::purple);
burgerMenuComponent.setModel(this);
setApplicationCommandManagerToWatch (&commandManager);
commandManager.registerAllCommandsForTarget (this);
commandManager.setFirstCommandTarget (this);
mainPopupMenu.addCommandItem(&commandManager, CommandIDs::columnOne);
mainPopupMenu.addCommandItem(&commandManager, CommandIDs::columnTwo);
}
BurgerMenu::~BurgerMenu()
{
commandManager.setFirstCommandTarget (nullptr);
burgerMenuComponent.setModel(nullptr);
}
StringArray BurgerMenu::getMenuBarNames()
{
return { "Menu Sub-Header" };
}
PopupMenu BurgerMenu::getMenuForIndex (int topLevelMenuIndex, const String& menuName)
{
return mainPopupMenu;
};
void BurgerMenu::menuItemSelected (int menuItemID, int topLevelMenuIndex)
{
// useless shit
};
void BurgerMenu::getAllCommands (Array<CommandID>& c)
{
Array<CommandID> commands { CommandIDs::columnOne,
CommandIDs::columnTwo };
c.addArray (commands);
}
void BurgerMenu::getCommandInfo (CommandID commandID, ApplicationCommandInfo& result)
{
//bool tick = false;
switch (commandID)
{
case CommandIDs::columnOne:
result.setInfo ("Column 1", "Edit Col 1", "Menu", 0);
std::cout << result.shortName << "\n";
break;
case CommandIDs::columnTwo:
result.setInfo ("Column 2", "Edit Col 2", "Menu", 0);
std::cout << result.shortName << "\n";
break;
default:
break;
}
}
bool BurgerMenu::perform (const InvocationInfo& info)
{
switch (info.commandID)
{
case CommandIDs::columnOne:
performAction();
break;
case CommandIDs::columnTwo:
performAction();
break;
default:
return false;
}
return true;
}
The SidePanel that ‘hosts’ the PopupMenu works fine, and the Sub-Header (MenuBar name) gets displayed fine, it simply does not display the CommandItems, I have tried debugging and apparently the parameters in getAllCommands and getCommandInfo are passed properly, nothing missing there.
Please HE LP!