SOLVED: Custom color for slider label editor

gui

#1

I have a slider with text box showing. I want the text to be white when displayed (this is working). When clicking to edit, the text stays white (but on a white background) so you can’t see what you’re typing. I tried the code below in L&F but the color is not changing. Am I using the right colour id?

Label* createSliderTextBox(Slider& slider) override
{
    Label* l = LookAndFeel_V2::createSliderTextBox(slider);
    l->setFont(labelFont);

    // make sure editor text is black (so it shows on white background)
    l->setColour(TextEditor::textColourId, Colours::black);

    return l;
}

#2

Check out the ColourIds for the Slider class:

https://bill-auger.github.io/JUCE/doxygen/doc/classSlider.html

Rail


#3

@Rail_Jon_Rogut, thanks for the suggestion but I forgot to mention I have done that. It has only one id for text color and that is textBoxTextColourId which sets the color of both the edit and non-edit text. This is the root of the problem. I want the non-edit text to be “white” and the edit text to be “black” but the one id sets both colors. I’d be happy with any suggestion how I can set the two colors independently via L&F or other reasonable thing.


#4
textBoxTextColourId:        The colour for the text in the text-editor box used for editing the value.

 textBoxHighlightColourId: 	The text highlight colour for the text-editor box.

Rail


#5

@Rail_Jon_Rogut, thanks once again for trying to help. However, that still isn’t it.

  • textBoxTextColourId - As noted, this is the font color for both modes: text edit and display.
  • textBoxHighlightColourId - This is the color of the text highlight. The color that “surrounds” the text when you first click on the box. When you start typing the highlight goes away like in any normal text editor.

Note: I did try it before and tried it again on your suggestion. I set it to red so it would be super obvious. It shows red “highlight” and behaves as described.


#6

You are setting it in the Label’s LnF, so the answer is no.
Try the ones from Label: Label::ColourIds

I guess it’s Label::textWhenEditingColourId.

HTH


#7

Ah yes, that was it. I don’t remember why I ended up in TextEditor ids instead, but Label::textWhenEditingColourId was the correct id.

Corrected/working code is:

Label* createSliderTextBox(Slider& slider) override
{
    Label* l = LookAndFeel_V2::createSliderTextBox(slider);
    l->setFont(labelFont);

    // make sure editor text is black (so it shows on white background)
    l->setColour(Label::textWhenEditingColourId, Colours::black);

    return l;
}

P.S. @Rail_Jon_Rogut I remember you from the old SAW days. You had the EDL software. I never used it, but it sticks out in my brain.