Transparent of outline of TextEditor

#1

In the JUCE documentation there is written:

outlineColourId - If this is non-transparent, it will be used to draw a box around the edge of the component.

But I can’t find anywhere the info how to make it transparent or not transparent. Could anyone help me?

0 Likes

#2
editor.setColour(TextEditor::outlineColourId, Colours::red); // non-transparent red
editor.setColour(TextEditor::outlineColourId, Colours::red.withAlpha(0.0f)); // transparent red

“Alpha” will be the same as “transparency” for colours

1 Like

#3

Great thanks, I tried that already, and it doesn’t work so I suppose it’s some problem with my lookAndFeelMethod in which I have method like that:

Label* createSliderTextBox(Slider &slider) override
{
	auto l = new SliderLabel();
	l->setJustificationType(Justification::centred);
	l->setKeyboardType(TextInputTarget::decimalKeyboard);
	l->setColour(Label::textColourId, slider.findColour(Slider::textBoxTextColourId));
    l->setColour(Label::outlineColourId, myColour);
    // ALL ABOVE WORKS

    // BUT THAT DOESN"T WORK:
    l->setColour(TextEditor::outlineColourId, Colours::black.withAlpha(1.0f));
    // NO MATTER WHAT COLOUR I USE THE OUTLINE OF TEXT EDITOR IS ALWAYS THE SAME.
}

I also wonder how to change the thickness of Label and TextEditor outlines.

0 Likes

#4

Components are only going to use the ColourIds associated with them generally, which is why Label::outlineColourId works and TextEditor::outlineColourId does not, and the default LookAndFeel doesn’t seem to try inheriting any ColourIds from parents in this case:

You’ll want to override that LookAndFeel maybe just use the same code but use findColour(..., true); inside those setColour() methods… the boolean argument tells findColour() that it should search the parent component as well

1 Like

#5

I will try that.
Thanks man

0 Likes