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.
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.
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.
This isn’t working for a PopupMenu either. Interestingly using withInitiallySelectedItem() will highlight the correct item in the submenu but you need to manually open the submenu to see it. Using withItemThatMustBeVisible() isn’t affecting that it seems.
Maybe I’m missing something but this seems like a bug to me.
Is there any way to open submenus already when showing a PopupMenu?