PopupMenu::CustomComponent bug


I’ve discovered a bug related to the highlighting of CustomComponents in a PopupMenu.

Behavior: CustomComponents cannot be highlighted because calling PopupMenu::CustomComponent::isItemHighlighted() always returns false.


void MyCustomComponent::repaint(Graphics &g)
if (isItemHighlighted()) // IS ALWAYS FALSE



Cause: When a CustomComponent is added to a PopupMenu via PopupMenu::addCustomComponent, the custom component is wrapped in a NormalComponentWrapper, which is a subclass of CustomComponent. Therefore when CustomComponent::setHighlighted is finally called in PopupMenu::highlightItemUnderMouse (via PopupMenu::setCurrentlyHighlightedChild), it is called on the the NormalComponentWrapper, which does not pass the information along to the user’s CustomComponent.



1 Like

Nevemind. I was using

void addCustomItem (int itemResultId, Component *customComponent, int idealWidth, int idealHeight, bool triggerMenuItemAutomaticallyWhenClicked)

instead of

void addCustomItem (int itemResultId, CustomComponent *customComponent)

I did read the “Appends a custom menu item that can’t be used to trigger a result.” documentation for the former, but was confused by the triggerMenuItemAutomaticallyWhenClicked parameter.

Sorry if I wasted anyone’s time!