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

moveTo() not scrolling the StyleClassedTextArea #652

Closed
jplwill opened this issue Nov 20, 2017 · 5 comments
Closed

moveTo() not scrolling the StyleClassedTextArea #652

jplwill opened this issue Nov 20, 2017 · 5 comments

Comments

@jplwill
Copy link

jplwill commented Nov 20, 2017

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);
    }
}
@JordanMartinez
Copy link
Contributor

moveTo moves the caret, but it no longer follows the caret. Add a requestFollowCaret() call after moveTo and that should fix your issue. Reopen if it doesn't.

@JordanMartinez
Copy link
Contributor

And shouldn't you be using the newer 0.8.1 version? It has better documentation.

@jplwill
Copy link
Author

jplwill commented Nov 20, 2017

Thanks, that did the trick!

Ultimately, yeah, I need to move up. But this is a test tool, and I just noticed that it wasn't working. I'd apparently missed the addition of requestFollowCaret() on my last upgrade and hadn't observed the problem...and the Google, it only showed me items from back in 2015.

@JordanMartinez
Copy link
Contributor

Ah... ok. Forewarning about the migration from 0.7-M5 and 0.8.1, it helps to know about SEG and how that works. To understand it better, you can read the wiki page that explains that more. Previously, SEG included the segment type and its style (0.7-Mx series) Now it refers only to the segment type (0.8.x series).

@jplwill
Copy link
Author

jplwill commented Nov 20, 2017

Thanks much!

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