# PopupMenu + alt key = hidden choices

**URL:** <https://forum.juce.com/t/popupmenu-alt-key-hidden-choices/37555>\
**Category:** General JUCE discussion\
**Created:** [February 11, 2020, 9:45am UTC](https://forum.juce.com/t/popupmenu-alt-key-hidden-choices/37555 "2020-02-11T09:45:57Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [February 11, 2020, 6:21pm UTC](https://forum.juce.com/t/popupmenu-alt-key-hidden-choices/37555/3 "2020-02-11T18:21:11Z")

</div>

This can’t be used with a MenuBarComponent.

What I need is

```auto
int MenuBarComponent::getCurrentPopupIndex() const { return currentPopupIndex; }

```

which doesn’t exist.

I got it working when I added that function to `MenuBarComponent` though:  
 ![popupMenu](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/d/d9d4c9256b1d9b40ba7ecee36ab8c39d62cf96ae.gif)

That’s via this:

```auto
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()`:

```auto
        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.

---

_[View the full topic](https://forum.juce.com/t/popupmenu-alt-key-hidden-choices/37555)._
