How to highlight with PopupMenu::CustomComponent


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.

hey jazzunko,

check out void Component::setInterceptsMouseClicks(bool allowClicksOnThisComponent,bool allowClicksOnChildComponents) Method in juce document

I am not very sure how you have managed your component and popupMenu’s custom component but might be it would help you, Adding this method to your custom component can help you get mouse movements over it.

Hi acn,

Thank you for your advice! In my code, when a component is clicked, a popup menu appears somewhere. I would like to get mouse events without mouse clicks. I tried setInterceptsMouseClicks method, but it controls events by mouse clicks. I will look into this behavior more details. Thank you :slight_smile:

Hey jazzunko,

Yes It controls and put you inside while mouse clickes are occured,

Like if you have customComponent in your poupMenu, and if you have implmented virtual methods like mouseMove(const MouseEvent & e) and other in customComponent, than it must come with mouse events while mouse moved over your particular customComponent inside popupmenu.

And may be you can do something like :
In your component in which you create poupMenu with customComponents. In your component if you have mouseMove(const MouseEvent & e) and when mouse moved over this component , check if current mouse position point are inside popupmenu’s bound (or PopupMenu’s child’s bound) . and acessing that child(customComponent of your popupMenu).

Has there been any development on this?

What I’m after is a callback when an item is highlighted in the popup menu, but there doesn’t appear to be an interface for this. I also tried overriding the mouseOver for a CustomComponent item however the event isn’t received until mouse down is selected, and I can’t seem to be able to move it to the front.