TextEditor::backgroundColourId changes?

I use a lookandfeel class and set the TextEditor::backgroundColourId in the constructor. Then painting the background with:

void MyLookAndFeel::fillTextEditorBackground (Graphics& g, int /*width*/, int /*height*/, TextEditor& textEditor) { g.fillAll (textEditor.findColour (TextEditor::backgroundColourId)); }

All is fine, except as soon as text is entered in the texteditor, the background color resets to white…

Changing to:

void MyLookAndFeel::fillTextEditorBackground (Graphics& g, int /*width*/, int /*height*/, TextEditor& textEditor) { g.fillAll (LookAndFeel::findColour (TextEditor::backgroundColourId)); }

solves the problem, but is this the right way to do this?

Yes, you’re probably best to do it that way if you want to override the background colour that’s set in the texteditor itself.