Brainduck icon indicating copy to clipboard operation
Brainduck copied to clipboard

Auto-scroll memory when selection goes outside the visible

Open Zomis opened this issue 9 years ago • 2 comments

Scroll the memory list when the current memory index is not visible

Zomis avatar Dec 02 '15 17:12 Zomis

This doesn't seem to be that easy, as JavaFX 8 doesn't seem to provide the methods one could expect for this.

  • [ ] Get ScrollBar from ListView and get the current scroll position of it
  • [ ] Get topmost index currently visible
  • [ ] Get number of indexes visible at any time

Some code I have been trying, none of which prints anything at all.

    for (javafx.scene.Node node : memoryList.lookupAll(".scroll-bar")) {
        if (node instanceof ScrollBar) {
            final ScrollBar bar = (ScrollBar) node;
            bar.valueProperty().addListener(new ChangeListener<Number>() {
                @Override public void changed(ObservableValue<? extends Number> value, Number oldValue, Number newValue) {
                    System.out.println(bar.getOrientation() + " " + newValue);
                }
            });
        }
    }

    this.memoryList.onScrollFinished = {ScrollEvent event ->
        def units = event.getTextDeltaYUnits()
        println "units $units y $event.y textDeltaY $event.textDeltaY sceneY $event.sceneY"
    } as javafx.event.EventHandler<ScrollEvent>

Zomis avatar Dec 05 '15 17:12 Zomis

This might help with implementing this: https://github.com/TomasMikula/Flowless See also the Javadoc for Cell.updateItem

Zomis avatar Dec 19 '15 16:12 Zomis