TextEditor::lookAndFeelChanged()

Hi,

I have hooked up an ApplicationCommandManager hot-key to switch between LookAndFeels. This works amazingly well, except for a snag with TextEditors. When the LookAndFeel changes, the TextEditor repaints its borders and background, but

a) does not update the text color, and
b) does not restore the caret.

I was able to fix b) by calling updateCaretPosition() from TextEditor::lookAndFeelChanged():

void TextEditor::lookAndFeelChanged() { if (isCaretVisible()) { setCaretVisible (false); setCaretVisible (true); updateCaretPosition(); } }
I don’t know what to do about a) though. The effect is rather entertaining, where text stays in the colour it was initially typed in, and flipping LookAndFeels allows me to type multi-colored text into the editor. :wink:

So I guess what I was hoping for is that the entire body text would change color to the new textColourId. Possible? Desirable?

Thanks!

Thanks - I’ll sort out the caret. The text colour’s not really possible though, because a text editor’s contents can be a mix of whatever colours the text was added with, so to just replace all that when the l+f changes would mess things up for people who don’t want that. If you have a specific type of text editor in your app that does behave like that, you could create a subclass for it?

That’s what I ended up with. And applyFontToAllText() did the trick just nicely. :wink: