FileBrowserComponent colours


#1

I am not having any success changing the the colours of a FileBrowserComponent. I have a custom LookAndFeel, on which I am calling setColour():

lookAndFeelCustom.setColour(FileBrowserComponent::currentPathBoxBackgroundColourId, Colours::hotpink);
LookAndFeel::setDefaultLookAndFeel(&lookAndFeelCustom);

Later on I add a FileBrowserComponent, but it doesn’t pick up my custom colour.

Any idea what I might have overlooked?


#3

OK, I have solved this one. The problem was simply one of timing. My FileBrowserComponent’s constructor was being called before I defined my L&F colours, so it didn’t know about the change. The fix was simply to let my FileBrowserComponent know about the change by calling sendLookAndFeelChange():

lookAndFeelCustom.setColour(FileBrowserComponent::currentPathBoxBackgroundColourId, Colours::hotpink);
LookAndFeel::setDefaultLookAndFeel(&lookAndFeelCustom);
sendLookAndFeelChange();

Rookie mistake!


#4

Allow me to continue my monologue!

While trying to solve an unrelated LookAndFeel timing issue, one which could not be solved by sendLookAndFeelChange, I stumbled upon a better approach that allows me to call setDefaultLookAndFeel before my other components’ constructors have run, eliminating the need for sendLookAndFeelChange altogether. You can find details in this post: Best place for custom look instantiation in a plugin?