Scroll Gesture in ListView

Johan Vos johan.vos at
Tue Oct 6 08:02:43 UTC 2015

I have the following issue:
Scrolling with inertia, initiated by a ScrollGesture, stops after a while
in a ListView.

The reason for this is the following: the javadoc for ScrollEvent has this:
The event is delivered to the top-most node picked on the gesture
coordinates in time of the gesture start - the whole gesture is delivered
to the same node even if the coordinates change during the gesture.

Looking into the code, this is indeed what happens: when a SCROLL_STARTED
is received, the targetNode is picked, and this is then used as the first
one in the dispatchchain for the remainder of the scroll event (even after
But the inertia scrolling causes new SCROLL events to be generated after
the SCROLL_FINISHED, and it will cause the ListView to scroll its items.
The initially selected cell might be reclaimed (or its contents are not
shown in the ListTile anymore, as this is re-used for other content).
In that case, the dispatch chain is broken, as the targetNode.getParent()
will return null, and the scroll event is never passed to the ListView.

There are a number of potentials solutions to this problem. Re-calculating
the pickedTarget on every SCROLL event seems not a good solution to me
(what are the pick coordinates after the touchpoint has been released? It
will slow down performance as well).
Rather, it would be better if somehow the pickedTarget for these events is
the ListView itself, and not one of its cells. We can already do this by
setting the ListCell and its content to mouseTransparent, but that will
make them unavailable for mouseClick events as well.

So it seems to me we need something like "gestureTransparent", by which we
can indicate a Node not to be interested in handling gestures. The code for
picking the target Node currently ignores the Node if it has the
mouseTransparent set. I would propose to add a gestureTransparent property
on Node, and to add the following check:
if we need to find the pickedTarget for a gestureEvent, it should never
return a node with gestureTransparent set to true.

This would require a change in Scene.ScenePeerListener.scrollEvent() where
the ScrollEvent is created, and where the pickTarget is computed by
pick(x,y) which only ignores mouseTransparent nodes at the moment.

Should I file an issue for this?

- Johan

More information about the openjfx-dev mailing list