Skip to content

moveTo() not scrolling the StyleClassedTextArea #652

@jplwill

Description

@jplwill

macOS 10.12.6, Java 1.8.0_101-b13, richtextfx-fat-0.7-M5.jar.

I have a StyleClassedTextArea wrapped in a VirtualizedScrollPane that I'm using as a log pane. After appending to the widget I call moveTo() to move to the bottom and display the next text; however, it isn't scrolling. It used to work, I'm pretty sure. Here's the code; to see the behavior run the app and press the "Log Stuff" button a few times.

public class App extends Application {
    private StyleClassedTextArea output;
    
    @Override
    public void start(Stage primaryStage) {
        BorderPane root = new BorderPane();

        output = new StyleClassedTextArea();
        output.setEditable(false);
        output.setWrapText(true);

        VirtualizedScrollPane<StyleClassedTextArea> vsPane = 
            new VirtualizedScrollPane(output);
        root.setCenter(vsPane);
        
        Button btn = new Button();
        btn.setText("Log Stuff");
        btn.setOnAction((ActionEvent event) -> {
            output.appendText("Line 1\n");
            output.appendText(" Line 2\n");
            output.appendText("  Line 3\n");
            output.appendText("   Line 4\n");
            output.appendText("    Line 5\n");
            output.appendText("     Line 6\n");
            output.appendText("      Line 7\n");
            output.appendText("       Line 8\n");
            output.moveTo(output.getLength());
        });
        
        root.setTop(btn);
        
        Scene scene = new Scene(root, 300, 250);
        
        primaryStage.setTitle("No Scroll");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions