Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.styled-text-area .caret seems not to work #1116

Open
PavelTurk opened this issue Jun 2, 2022 · 1 comment
Open

.styled-text-area .caret seems not to work #1116

PavelTurk opened this issue Jun 2, 2022 · 1 comment

Comments

@PavelTurk
Copy link

This is java code:

public class JavaFxTest2 extends Application {

    private final InlineCssTextArea textArea = new InlineCssTextArea();

    private final VirtualizedScrollPane scrollPane = new VirtualizedScrollPane(textArea);

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        textArea.setWrapText(true);
        textArea.setEditable(true);
        textArea.setParagraphGraphicFactory(LineNumberFactory.get(textArea));
        textArea.setPadding(new Insets(0, 0, 0, 0));
        var ss = "Some text here";
        VBox.setVgrow(scrollPane, Priority.ALWAYS);
        VBox root = new VBox();

        root.getChildren().addAll(scrollPane, new TextField());
        textArea.setWrapText(true);
        var css = this.getClass().getResource("console.css").toExternalForm();
        var scene = new Scene(root, 450, 450);
        scene.getStylesheets().add(css);
        primaryStage.setScene(scene);
        primaryStage.show();
        textArea.appendText(ss);
    }
}

This is css:

.root {
    -fx-font-size: 20;
}

.styled-text-area .caret {
    -rtfx-blink-rate: 5000ms;
    -fx-stroke-width: 10.0;
}

Caret seems to blink with the same rate, and with one pixel width. Is this correct behavior?

@Jugen
Copy link
Collaborator

Jugen commented Jun 3, 2022

Here's a work-around:

textArea.setId( "myarea" );
#myarea .caret {
    -rtfx-blink-rate: 5000ms;
    -fx-stroke-width: 10.0;
}

Explanation: CSS is applied from least specific to most specific, with the most specific selector overriding the lesser.
Since the default CSS in "styled-text-area.css" for -rtfx-blink-rate is already highly specified as .styled-text-area .caret we need to use the Node Id specifier to override it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants