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

Question: is it possible to disable scrolling to bottom on appending text? #1221

Closed
PavelTurk opened this issue May 6, 2024 · 2 comments
Closed

Comments

@PavelTurk
Copy link
Contributor

When I open file with with my text area I use the following code:

        CodeArea textArea = ...
        textArea.clear();
        textArea.appendText(t);
        textArea.getUndoManager().forgetHistory();
        textArea.getUndoManager().mark();

However, after that text area is scrolled to bottom. If I add to my code:

    textArea.moveTo(0);
    textArea.requestFollowCaret();

Then textarea is scrolled to top, but there is a flickering of vertical bar and it is not good. Could anyone say how to disable scrolling to bottom on text appending? Or maybe there are other solutions?

@Jugen
Copy link
Collaborator

Jugen commented May 7, 2024

You can try the following:

    textArea.clear();
    textArea.appendText( "\n" );
    textArea.selectRange( 0, 0 );

    var changes = textArea.createMultiChange(2);
    changes.insertTextAbsolutely( 0, 1, sampleCode );
    changes.deleteTextAbsolutely( 0, 1 );
    changes.commit();

@PavelTurk
Copy link
Contributor Author

@Jugen Yes, it helped. Thank you very 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