CustomComponent isItemHighlighted() not working on macOS

I have a combo box with my own CustomComponent items.

When my mouse moves over a normal text popup menu, then the menu item under the mouse position is always highlighted. I can’t make this work for CustomComponent items.

In the paint method I’m using:

g.fillAll(isItemHighlighted() ? juce::Colour(0xFF444444) : juce::Colour(0x0));

This does not work (tested on macOS), even with a timer calling repaint() all the time.

Similar thread about that problem:

For ComboBoxes .withInitiallySelectedItem (box.getSelectedId()) is default. isItemHighlighted() is always false in my case on macOS.

I also have a combobox with my own CustomComponent items and isItemHighlighted() works on mouseOver for me here (au and vst3 in reaper, latest juce), with just that bit added to my custom component:

void paintOverChildren (juce::Graphics& g) override
{
    if (isItemHighlighted())
        g.fillAll (juce::Colours::white.withAlpha (0.1f));
}

but the currently selected item (set via .withInitiallySelectedItem (box.getSelectedId())) isn’t highlighted. The highlighted item is cleared cause the mouse isn’t over it. But that’s the expected behaviour according to the doc of isItemHighlighted():
Returns true if this item should be highlighted because the mouse is over it

1 Like