JavaFX - RichTextFX - How to change highlight text color

396 views Asked by At

I am using an instance of RichTextFX's StyleClassedTextArea, but can't seem to change the color of the text itself while highlighting.

There is a similar question: RichTextFx change selected text color and line number background which has helped me, but the answer only changes the actual highlight color, not the text itself while highlighted. I want the highlighted text itself to be white so it is more-readable.

The answer from the other question is as follows:

.styled-text-area .selection {
    -fx-fill: pink;
}

I have tried other ways to get the text itself to change color such as:

.styled-text-area .selection .text {
    -fx-fill: white;
}


.styled-text-area .selection {
    -fx-highlight-fill: white;
}

But I can't seem to get anything to work. The normal -fx-text-fill syntax does not seem to work with RichTextFX.

1

There are 1 answers

0
Nmare418 On

you can try -rtfx-background-color: yellow;