Could you link the scrolling to a Timeline animation?
Then the button could control the start and stop of the timeline.
For example, this is similar but it controls the rotation of a square (maybe you could use a TranslateTransition):
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.animation.transition.RotateTransition;
import javafx.animation.Timeline;
import javafx.scene.control.Button;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.animation.Interpolator;
def r = Rectangle {
x: 80 y: 80
height: 100 width: 100
arcHeight: 50 arcWidth: 50
fill: Color.VIOLET
}
def rotTransition = RotateTransition {
duration: 1s
node: r
byAngle: 180
repeatCount: Timeline.INDEFINITE
interpolator: Interpolator.LINEAR
}
def b = Button {
text: "Click and hold"
onMousePressed: function (e) {
rotTransition.play();
};
onMouseReleased: function (e) {
rotTransition.stop();
};
};
Stage {
title : "Rotation"
scene: Scene {
width: 250
height: 250
content: [r,b]
}
}