TextEditor text colour not updated after lookAndFeelChanged()/parent change

Hi all,

I’m working with my own custom LookAndFeel, set at the main component. When I dynamically addAndMakeVisible a component containing a TextEditor, the text colour remains the default colour, even though my custom LookAndFeel changed it. The editor does use all the other colours (background, outline, highlight) correctly, just not the text colour itself. This seems to be a bug.

I’m guessing the problem has to do with something in the editor caching the text colour and not updating correctly on a lookAndFeelChanged(). When I change the editor content by calling setText(), the colour is being updated.

A TextEditor can actually contain text that’s a combination of different colours and fonts, so the colour from the L+F is really only a default that it’ll use if it’s currently empty - it won’t automatically change the colour of all the text because it could have been explicitly set by the user.

Ah ok then! Makes sense. Is there a way to force the text editor to take over the colour from the L+F without having to pull that from the L+F myself, then? That kind of seems to beat the purpose of the L+F system, though I see what you’re getting at with attributed text and all.

I think you’d just have to set it yourself - it’s only a one-liner to do that. Or just make sure the L+F is applied before you put any text into the editor

Alright, thanks! Just went with this (if anyone else reads this):

void parentHierarchyChanged() final
    textEditor.applyColourToAllText(getLookAndFeel().findColour(juce::TextEditor::ColourIds::textColourId), true);