Changing the colour of the listbox in the FileBrowserComponent

Hi, having trouble getting to this to change the colours for this. I’m setting the land and feel colours for ListBox::textColourId etc but doesn’t seem to be having any effect. Are these the things I should be changing?

thx

ListBox::backgroundColourId should do the trick.

hi, thx - that’s what I thought - not seeming to have any effect for some reason… I have lots of other colours set in the lookandfeel which are all being picked up, but these aren’t…

If you’re using the setColour() method to do this make sure you’re calling it on the LookAndFeel object and not just a specific Component by doing something like:

Desktop::getInstance().getDefaultLookAndFeel().setColour (ListBox::backgroundColourId, Colours::hotpink);

Ed

I have a custom LookAndFeel object which I set everything on and then call LookAndFeel::setDefaultLookAndFeel() which should do the same thing? As said, it works for lots of other colours, just not these listbox colours…

Yep that should work. Just to be clear, you’re talking about setting the background colour of this part of the FileBrowserComponent, right?

yes. want the background to be black and the text to be white.

m_laf.setColour( ListBox::textColourId, Colours::white );
m_laf.setColour( ListBox::outlineColourId, Colours::white );
m_laf.setColour( ListBox::backgroundColourId, Colours::black );
    
LookAndFeel::setDefaultLookAndFeel( &m_laf );

The background colour is set using ListBox::backgroundColourId but the text of the file browser rows is set using DirectoryContentsDisplayComponent::textColourId. Can you try running this simple GUI app and see if it works for you?

MainComponent.h (2.6 KB)

hi - thanks, that works fine.

Interestingly enough, the text colour change works, and the background colour does take effect for a standard listbox, just not the filechooser… As your example works perfectly, I can only assume that I’m doing something strange somewhere…

ok, i’m subclassing FileBrowserComponent to override some of the callbacks… when i do that it no longer appears to paint the background so the parent just shows through

That’s strange - what methods are you overriding?

well, I’ve been a bit of a dick here - I failed to take on board the fact that I’d changed the type of the browser to a tree view so obv I needed to change the colours IDs too…

sorry for wasting your time!

No problem, glad you’ve fixed it!