TextEditor::recreateCaret() issue


#1

I suspect it has to do with this change…

I have a textEditor with a LookAndFeel which changes the cursor color… which used to work fine… But I just noticed that the cursor color isn’t changed… and TextEditor:: recreateCaret() isn’t triggered when you click on the Editor. drawTextEditorOutline() is called… but the call to my LookAndFeel createCaretComponent() never happens.

Thanks,

Rail


#2

enablementChanged is called in response to setEnabled(), not when it gains/loses focus, which seems to be what you're talking about here. 

You probably want focusGained/focusLost() instead?


#3

Sorry I revised my post to be more accurate…

The issue has to do with a change in behavior – so my LookAndFeel createCaretComponent() is never being called.

Rail


#4

If I add a call to recreateCaret() in focusGained() it still doesn’t update the caret 'cause it isn’t == nullptr

Rail


#5

Okay…. the fix is:

void TextEditor::lookAndFeelChanged()
{
    caret = nullptr;
    recreateCaret();
    repaint();
}

Rail


#6

+1


#7

Thanks, seems like a good idea, will add that!