This can’t be used with a MenuBarComponent.
What I need is
int MenuBarComponent::getCurrentPopupIndex() const { return currentPopupIndex; }
which doesn’t exist.
I got it working when I added that function to MenuBarComponent
though:
That’s via this:
void MenuBarUpdater::timerCallback()
{
if( mbc != nullptr )
{
auto& desktop = Desktop::getInstance();
bool isAltDown = desktop.getMainMouseSource().getCurrentModifiers().isAltDown();
if( isAltDown != lastAltStatus )
{
lastAltStatus = isAltDown;
auto currentMenuIndex = mbc->getCurrentPopupIndex();
if( isAltDown && currentMenuIndex >= 0 )
activeMenuIndex = currentMenuIndex;
refresh();
}
}
}
void MenuBarUpdater::refresh()
{
mbc->showMenu(-1); //closes current menu
DBG( "activeMenuIndex: " << activeMenuIndex );
mbc->showMenu(activeMenuIndex); //forces current menu to be recreated.
}
and doing this in getMenuForIndex()
:
if( Desktop::getInstance().getMainMouseSource().getCurrentModifiers().isAltDown() )
{
menu.addSeparator();
menu.addSubMenu("Font",
createFontMenu(settingsTree));
}
CC: @t0m @jules I’ll be submitting a pull request for that MenuBarComponent
index getter.