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

Horizontal Scroll Bar does not work correctly with LineNumberFactory #1030

Closed
atsepushel opened this issue Jul 16, 2021 · 2 comments · Fixed by FXMisc/Flowless#100
Closed

Comments

@atsepushel
Copy link

Expected Behavior

CodeArea always showing caret (scrolling to visible) on keyboard moving (left/right buttons)

Actual Behavior

CodeArea not showing caret on keyboard moving (left/right buttons). Scroll begin moving only after few keyboard "right" button clicks, looks depended on LineNumberFactory nodes width

Reproducible Demo

  • Your default JavaKeywordsDemo.java
  • Run and change window width for showing horizontal scroll bar
  • photo_2021-07-16_19-46-06
  • Set caret position to the end of the line that is not fully visible and tries move with the keyboard to the right
  • Visible area begin moving only after few buttons button clicks

Environment info:

  • RichTextFX Version: 0.10.6
  • Operating System: Windows 10
  • Java version: 1.8.0_112
@atsepushel atsepushel changed the title Horizaontal Scroll Bar does not work correctly with LineNumberFactory Horizontal Scroll Bar does not work correctly with LineNumberFactory Jul 16, 2021
@appsofteng
Copy link

The line number label must move by breadth offset when the view port moves. Currently the offset is updated several times and one update is 0 which keeps the line number at the beginning of the virtual flow.
The solution I used is to prevent multiple offset update by removing and then adding listeners in org.fxmisc.flowless.VirtualizedScrollPane
This prevents event cycling.

Original:

    private final ChangeListener<Double> hbarValueListener;
    private final ChangeListener<Double> hPosEstimateListener;
    private Var<Double> hbarValue;
    private Var<Double> hPosEstimate;

    hbarValueListener = (observable, oldValue, newValue) -> hPosEstimate.setValue(newValue);
    hbarValue.addListener(hbarValueListener);
    hPosEstimateListener = (observable, oldValue, newValue) -> hbarValue.setValue(newValue);
    hPosEstimate.addListener(hPosEstimateListener);

Changed:

    private ChangeListener<Double> hbarValueListener;
    private ChangeListener<Double> hPosEstimateListener;
    private Var<Double> hbarValue;
    private Var<Double> hPosEstimate;

    hbarValueListener = (observable, oldValue, newValue) -> {
	hPosEstimate.removeListener(hPosEstimateListener);
        hPosEstimate.setValue(newValue);
        hPosEstimate.addListener(hPosEstimateListener);
    };
    hbarValue.addListener(hbarValueListener);

    hPosEstimateListener = (observable, oldValue, newValue) -> {
        hbarValue.removeListener(hbarValueListener);
        hbarValue.setValue(newValue);
        hbarValue.addListener(hbarValueListener);
    };
    hPosEstimate.addListener(hPosEstimateListener);

@Jugen
Copy link
Collaborator

Jugen commented Oct 19, 2021

@appsofteng thanks very much for this, have submitted a PR in Flowless to fix this.

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

Successfully merging a pull request may close this issue.

3 participants