PopupMenu custom component isItemHighlighted

Hi Guys,

Looks like isItemHighlighted is never reseted when opening back the menu.
If I open the menu, select an item then open back the menu, the item is still highlighted.
Now I open the menu change the selection but discard the menu, open it back, no item are highlighted

If I use isMouseOver directly then it behave correctly.
Normal ?

Thanks !

isMouseOver is not reliable in DAW after all.

So fixing isItemHighlighted would be the best :smiley:

bump :slight_smile:

bump :slight_smile:

Are you opening the menu with PopupMenu::Options::withInitiallySelectedItem() ?

It’s used in a combo box and I use getRootMenu, then add custom items (addCustomItem) and that’s it.
I override the paint method of my PopupMenu::CustomComponent and check inside isItemHighlighted()

combobox call this option through the LnF
return PopupMenu::Options().withTargetComponent (&box)
.withItemThatMustBeVisible (box.getSelectedId())
.withInitiallySelectedItem (box.getSelectedId())
.withMinimumWidth (box.getWidth())
.withMaximumNumColumns (1)
.withStandardItemHeight (label.getHeight());

so I can maybe hack this. My main issue is that the highlighted one is actually not the selected id.
Still I can try to disable this in the LnF to avoid the issue.

Thanks !

I was recently having similar problems and that solved it for me. i.e.:

    menu.showMenuAsync(PopupMenu::Options().withTargetComponent(this).withInitiallySelectedItem(selectedItem), callback);

Also, my case may be different because I was designing a Button with a popupmenu containing CustomMenuComponents (little images), but you can use PopupMenu::CustomComponent::setHighlighted() to manually clear/control highlighting.

I was able to fix my issue using .withInitiallySelectedItem (box.getSelectedId())
but this means that if it ins’t set the status is quite bogus so it still looks like a bug to me.
There is no way to have a good behavior without any initially selected item