LookAndFeel request : getTextEditorFont()


#1

At the moment there is no way to define the TextEditors’ font via our lookAndFeels!

Could we have the following added to TextEditor::LookAndFeelMethods ?

virtual Font getTextEditorFont (TextEditor&) = 0;

with the following default lnf implementation :

Font LookAndFeel_V2::getTextEditorFont (TextEditor& textEditor)
{
    return textEditor.getFont();
}

it would also make sense to have a `virtual void drawTextEditor (Graphics&, TextEditor&) = 0;


#2

Well… the TextEditor actually allows a mixture of fonts in the text, so not sure how it’d use a L+F like that?


#3

just by calling getLookAndFeel().getTextEditorFont (*this) instead of getFont() in TextEditor::paintOverChildren() ?


#4

But that doesn’t draw the actual text, it just draws the string that you can make it show when the box is empty. Is that what you’re trying to customise?


#5

ah, yes, sorry. I guess the change would be in setText() then :

auto font = getLookAndFeel().getTextEditorFont (*this);
insert (newText, 0, font, findColour (textColourId), 0, caretPosition);

instead of the actual
insert (newText, 0, currentFont, findColour (textColourId), 0, caretPosition);

?


#6

But the idea is that people can set the current font, then insert text with that font, then change it, insert some other text, etc…


#7

Yes, I know, and that would still work fine if the default getTextEditorFont() implementation just return textEditor.getFont()

anyway, I just thought about something : I can actually just use an editable Label. It’s more appropriate for my purpose, and I’ll have getLabelFont() and the level of customization I need.

thanks jules