Open PavelTurk opened 1 month ago
Yeah, at least one layout pulse must occur for the value to update. What happens is that "Platform.runLater" is bundled into the same layout pulse as "scrollYBy" so the value hasn't been updated yet. So you need something like the following:
scrollButton.setOnAction(e -> {
System.out.println("Before scrolling first cell index: " + flow.getFirstVisibleIndex());
flow.scrollYBy(flow.getHeight());
scene.addPostLayoutPulseListener( new WaitForScrollYPulse( scene ) );
});
private class WaitForScrollYPulse implements Runnable
{
private Scene scene;
private int pulseCount = 0;
public WaitForScrollYPulse( Scene scene )
{
this.scene = scene;
}
@Override
public void run()
{
if ( ++pulseCount > 1 )
{
scene.removePostLayoutPulseListener( this );
System.out.println("After scrolling first cell index: " + flow.getFirstVisibleIndex());
}
}
}
This is my test code:
If you push button you will get the following output:
I tried:
but the result was the same.