FXMisc / RichTextFX

Rich-text area for JavaFX
BSD 2-Clause "Simplified" License
1.22k stars 236 forks source link

Is it possible to set style in InlineCssTextArea from some point and until it is overridden? #1247

Closed PavelTurk closed 1 month ago

PavelTurk commented 1 month ago

This is my test code:

public class RichTextFxTest extends Application {

    private final InlineCssTextArea textArea = new InlineCssTextArea();

    @Override
    public void start(Stage stage) throws Exception {
        var root = new VBox(textArea);
        textArea.append("My first text. ", "-fx-fill: green;-fx-font-weight:bold");
        textArea.append("My second text. ", "-fx-fill: red;");
        var scene = new Scene(root, 300, 200);
        stage.setScene(scene);
        stage.show();
    }
}

And this is the result:

Screenshot from 2024-10-31 15-48-42

I append the first text with bold font weight and I want this style was set to all texts until I set -fx-font-weight: normal. However, as you see in the picture the second text is not bold (although I didn't do -fx-font-weight: normal).

Could anyone say how to do it, if it is possible?

Jugen commented 1 month ago

I don't think it can be done without coding it.

PavelTurk commented 1 month ago

@Jugen Thank you very much for your reply. I thought that is not possible, but decided to clarify.