# CustomComponent isItemHighlighted() not working on macOS

**URL:** <https://forum.juce.com/t/customcomponent-isitemhighlighted-not-working-on-macos/65629>\
**Category:** MacOSX and iOS\
**Created:** [March 26, 2025, 8:24am UTC](https://forum.juce.com/t/customcomponent-isitemhighlighted-not-working-on-macos/65629 "2025-03-26T08:24:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kunz](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kunz](https://forum.juce.com/u/kunz)\
**Post date:** [March 26, 2025, 8:24am UTC](https://forum.juce.com/t/customcomponent-isitemhighlighted-not-working-on-macos/65629/1 "2025-03-26T08:24:03Z")

</div>

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:

> [@How to highlight with PopupMenu::CustomComponent](https://forum.juce.com/t/how-to-highlight-with-popupmenu-customcomponent/7759):
>
> Hi, I’m making a customized popup menu with PopupMenu::CustomComponent to show image icons on each menu item. I want to highlight(paint) an item while it’s under mouse over, but cannot get the state with isMouseOver(), getComponentUnderMouse() etc in my class derived from CustomComponent. Also, mouseDown is called when I click any item once. How can I highlight with CustomComponent? Thank you.

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [March 26, 2025, 9:27am UTC](https://forum.juce.com/t/customcomponent-isitemhighlighted-not-working-on-macos/65629/2 "2025-03-26T09:27:47Z")

</div>

> [@PopupMenu custom component isItemHighlighted](https://forum.juce.com/t/popupmenu-custom-component-isitemhighlighted/56697/7):
>
> 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.

---

<div class="post-metadata">

**Author:** ![kunz](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kunz](https://forum.juce.com/u/kunz)\
**Post date:** [March 26, 2025, 9:50am UTC](https://forum.juce.com/t/customcomponent-isitemhighlighted-not-working-on-macos/65629/3 "2025-03-26T09:50:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lalala](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/lalala/32/8577_2.png) [@lalala](https://forum.juce.com/u/lalala)\
**Post date:** [June 4, 2025, 1:45pm UTC](https://forum.juce.com/t/customcomponent-isitemhighlighted-not-working-on-macos/65629/4 "2025-06-04T13:45:39Z")

</div>

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:

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