I just noticed that when you click on a label it creates a textEditor and the text in that editor (once you type some) is black (regardless of the lookAndFeel colour settings).
If selected, it changes to the proper TextEditor highlightedTextColourId colour, but then goes back to black if you start typing.
Once the label loses focus it goes to the Label::textColourId of course.
Anyway, that’s different from how textEditors behave and seems kinda wonky.
Here’s what I have in my LookAndFeel class. Let me know if there is some colour I am missing that would override that white.
TextEditors that are created from Labels don’t get all the proper color (err … colour) info from the Label’s set LookAndFeel. So, if I override the drawLabel method in my lookAndFeel class I can change this colour.
So … if you specify TextEditor colors in a LookAndFeel object, and then set that LookAndFeel as the default for a project, then create a label, you will notice that the textEditor created by the label (when it is double clicked on) does NOT use the specified LookAndFeel.
Similarly, some elements created by various custom dialogs (file browsers, etc) don’t use certain LookAndFeel Colors that you would expect them to use (the file browser created from the PluginBrowser object is one).
I’ve fixed this where I could in my LookAndFeel class with things like:
No, not true - it definitely does use the normal l+f. But it does inherit any expliticly-specified colours from the label, so that it matches it. Have a look at Label::createEditorComponent(), and maybe override that if you want to avoid those colours being inherited.
This is annoying, since it makes it impossible to set the default color for the textEditors that are created by Labels (the text is always black). Couldn’t you use findColour() instead, and set Labels to create textEditors with the default Texteditor textColour?
That wouldn’t really work, because if needs to override the colours in the default l+f… Why not call Component::removeColour() to clear those from your label?
Yeah, there are a bunch of ways to do it individually, on each Label.
There really should be a way to set the textColor globally though, right?
Overriding it in the default l+f currently doesn’t work either, since it literally specifies Colours::black in the Label constructor.
What if you made the Label constructor use the default l+f instead of Colours::black, then it would be easy enough to specify the Color in the default l+f, yeah?
Well, there’s only one default l+f globally, but the label wants its text box to have a different background colour to the default one (i.e. it wants it to match the label’s background colour).
No no … we’re not talking about the background colour … that does match (the Label BG, as it should).
But the TEXT colour does not. Text colours in Label created textEditors are always BLACK! Which is annoying if you are doing a dark background color scheme!
I wasn’t actually talking about Slider related textboxes, just ones created from a normal Label.
But yeah, I see that the slider related Labels and Textboxes use the TextBoxColour Ids (as one might expect).
Uncustomized Labels however, do not.
Really, it doesn’t matter much to me, I have this working by overriding a bunch of LookAndFeel methods.
But for the novice, it seems confusing that you can specify every Label and TextEditor related colour, and still get black text when you edit the label. I know it took me a long time to figure out how to override that when I first looked at it.
So which looks and feels need to be overridden? Just DrawLabel? Because that hadn’t solved if for me. It looks like the drawing of the text is done in the TextEditor when it’s being edited, as it has to break text up into regions of contiguous style (i.e. selected vs unselected parts). I tried hacking that a bit but hopefully you’ve got an easier way Aaron?
Just wanted to chime in that I just encountered this problem, and found this thread, so Jules, would be good if you take a look, seems to be a common point of confusion. Just to clarify what the problem is, if you create a Label that has been .setEditable (true, false, true), when you click the Label, the resulting editor’s text is always black. Confused me for a good half an hour.
Is there really a bug that needs fixing here? Some people will want to be able to specify a different colour for the text when it's being edited, so having two text colour settings doesn't seem like a problem to me.
..would give you a red label that changes to blue text when edited.
I guess I could add some extra logic to see whether a TextEditor::textColourId colour has been specified, and to default to the label colour if not, but it all gets a bit hairy because there are per-component and per-lookandfeel colour settings, so someone may want to use the editor colour that's specified by their L+F, but still want to override the label colour in the component.