Is it possible to disable highlighting on a TextEditor?



I have a few situations where I’d like to have a TextEditor that contains information, that isn’t editable, can scroll, and doesn’t allow the user to highlight the text. I disable “editable” in the Projucer, which keeps the user from being able to change it, but highlighting is still available.

A label then seems to be what I want, since it isn’t editable (by default) and can’t be highlighted, but a label can’t scroll (to my knowledge, but I could be wrong).

So, is it possible to remove the highlighting functionality of a TextEditor or add scrolling abilities to a label? I assume if I override either, I could do it, just didn’t know if there was an easier solution.


perhaps setting the highlight colour transparent would do? (cf TextEditor::highlightColourId)

One solution is to use a slider.
You would just give it a particular look and feel overriding getSliderLayout() to set the label bounds appropriately, and you could override createSliderTextBox() to return a specific Label that can be dragged.

struct SliderLabel : public Label
    void mouseDrag (const MouseEvent& e) override
        if (auto* s = findParentComponentOfClass<Slider>())
            s->mouseDrag (e);

Label* createSliderTextBox (Slider&) override
    return new SliderLabel();


The first solution was simple enough. I’m not familiar with the colourId system JUCE uses and haven’t really dug into it to figure how to syntactically format the code to change things, but this wasn’t bad:

myTextEditor->setColour(TextEditor::highlightColourId, Colours::transparentWhite);

Thanks a bunch. I will dig into the code you posted as well to get a better understanding of the alternative solution.