DaddyRatel
DaddyRatel

Reputation: 739

Text background color in RichTextFx CodeArea

I'm using RichTextFx (CodeArea) to highlight my code. I want to change text background color for some keywords and use css below:

.parameter {
    -rtfx-background-color: yellow;
}

But it's changes background color for all text between my keywords (:p1 and :p2 in this example). Font color and style change successfully. enter image description here

Upvotes: 3

Views: 1545

Answers (2)

Stefan
Stefan

Reputation: 1

Just encountered the same problem.

To override JavaFX default styles in RichTextFX, use !important in your CSS. For example, -fx-background-color: #1E1E1E !important; ensures the background color is applied even if other styles are set, ensuring that your custom background color takes precedence.

Upvotes: 0

blaze-centurion
blaze-centurion

Reputation: 75

use StyleClassedTextArea.setStyleClass(from, to, "class Name"); to add class name to some specific range.

Upvotes: 1

Related Questions