Open a Popupmenu and have it show the item in sub-menu?

Hey,

Just working on a PopupMenu here and struggling to find if it is possible for a PopupMenu to show a selected item that is residing in a submenu when the PopupMenu first opens?

Thanks,
Gavin.

Looks like the way to go is to return the selected item via applied LookAndFeel…

 PopupMenu::Options getOptionsForComboBoxPopupMenu (ComboBox& box, Label& label) override
 {
        return PopupMenu::Options().withItemThatMustBeVisible (box.getSelectedId());
 }

Nope, not working here.

Not sure how to get this to work. If the item.id resides in a submenu then it won’t show that item when the pop menu is opened.

Any clues?

Is it for a ComboBox?

Yes for a ComboBox.

I’ve tried using the the Popupmenu directly using below, but still also doesn’t work as expected. I would think that withItemThatMustBeVisible would include itemIDs added in a submenu.

I can confim that It doesn’t work for submenus. :thinking: Anyway default is…

PopupMenu::Options LookAndFeel_V2::getOptionsForComboBoxPopupMenu (ComboBox& box, Label& label)
{
    return PopupMenu::Options().withTargetComponent (&box)
                               .withItemThatMustBeVisible (box.getSelectedId())
                               .withInitiallySelectedItem (box.getSelectedId())
                               .withMinimumWidth (box.getWidth())
                               .withMaximumNumColumns (1)
                               .withStandardItemHeight (label.getHeight());
}

…thus it is already done like that. Don’t know if it is a feature or a bug.

The ComboBox doesn’t check in submenus when looking for the visible item.
AFAIK the ComboBox widget was not designed at first to handle sub-menus.