Changing color of combobox elements in JUCE

Hello and thanks for a great framework. One question, how do I change colors of the fields as shown in the picture below? Been looking for a solution for this.



I think those would be PopupMenu::highlightedBackgroundColourId and PopupMenu::backgroundColourId

1 Like

That doesn’t worked either. Any other suggestion, I am having the same problem here. I
have my combobox and this
setColour (ComboBox::backgroundColourId, Colours::black);

but when I do this, doesn’t work
setColour (PopupMenu::backgroundColourId, Colours::black);

Hope you can give me a hint.

A combobox is actually multiple components. While I have not done this, I wonder if you need to use PopupMenu* ComboBox::getRootMenu () to access the popup menu, and use setColour on the PopupMenu component instead of the top level ComboBox component.

Alas, a PopupMenu is no Component. It uses a MenuWindow as Component instead. But that is not easily accessible (if at all). Hence there is no setColour() on PopupMenu.

I prepared a PR to store a SafePointer to the targetComponent and use it in findComponent of the PopupMenu::LookAndFeelMethods.

If somebody had answered in the feature request thread, I could add it there, but the forum doesn’t allow monologues :wink:


So how do I use it?

You have to patch your juce copy with the PR I linked. That way your popup menu will use the colours from the targetComponent, that you supplied in the PopupMenu::Options when creating the popup menu.

I will rebase the PR to see, if it still works out of the box. Sadly the JUCE team did neither pick that up nor came up with their own fix.

Maybe if you vote for the FR thread I linked in the post above… though my hope is little, didn’t see the FRs moving anything