Can't read text in a readonly TextEditor

I have my own LookAndFeel class that inherites from public juce::LookAndFeel_V4.

In my constructor I have:

setColourScheme(getLightColourScheme());

setColour(TextEditor::ColourIds::outlineColourId, OUTLINE_COLOUR_ID);
setColour(TextEditor::ColourIds::focusedOutlineColourId, FOCUSED_OUTLINE_COLOUR_ID);
setColour(TextEditor::ColourIds::textColourId, TEXT_COLOUR_ID);

where:
#define OUTLINE_COLOUR_ID Colours::black
#define FOCUSED_OUTLINE_COLOUR_ID Colours::black
#define TEXT_COLOUR_ID Colours::black

My TextEditor is initialized like this:
logOutput.setReadOnly(true);
logOutput.setMultiLine(true);
logOutput.setText(“bla\nblbalb\nbli”);
addAndMakeVisible(logOutput);

And I only manage to see something if I select the text. How can I make it black even that is readonly?

image

did you apply you’re lookandfeel before setting the text?
otherwise you would have to use applyColourToAllText()

Hi, yes, at the beginning of my MainComponent constructor I call first thing:

setLookAndFeel(&ownLookAndFeel);

now I added
logOutput.applyColourToAllText(Colours::black);
logOutput.setReadOnly(true);
logOutput.setMultiLine(true);
logOutput.setText(“bla\nblbalb\nbli”);
addAndMakeVisible(logOutput);

and it works (yey!) but does it mean I have to do that in every single text editor? I thought the LookAndFeel should apply that to all the TextEditors. What’s the point of setting this then?

setColour(TextEditor::ColourIds::textColourId, TEXT_COLOUR_ID);

Oh I just found this thread: TextEditor text colour not updated after lookAndFeelChanged()/parent change - #2 by jules

Meaning that thats for the default text but still I don’t understand why if I:

  1. set a lookAndFeel
  2. setText in my TextEditor
    It doesn’t apply the default colour from lookAndFeel.

If I TYPE something new then it’s black as I selected. But the text setted with setText is still white.

Ok, me again.

This also works:
//logOutput.applyColourToAllText(Colours::black);
logOutput.setLookAndFeel(&ownLookAndFeel);
logOutput.setReadOnly(true);
logOutput.setMultiLine(true);
logOutput.setText(“bla\nblbalb\nbli”);
addAndMakeVisible(logOutput);

I thought if I set the lookAndFeel for MainComponent, all it’s children would have the same lookAndFeel.

It’s wierd because some of the changes I made in my ownLookAndFeel are being applied even that I didn’t set it in the child component. For example:

setColour(ComboBox::ColourIds::outlineColourId, OUTLINE_COLOUR_ID);

All my comboBoxes took the new colour even that I didn’t apply the lookAndFeel to each of them.

I’m very confused now!

sorry, had my coffee and realised that I just needed to do

LookAndFeel::setDefaultLookAndFeel (&ownLookAndFeel);

to set the whole lookAndFeel. Doh!

1 Like