On Tue, 2 Jun 2026 16:33:05 GMT, Martin Fox <[email protected]> wrote:

>> On macOS when the user swipes on a trackpad or Magic Mouse JavaFX sees this 
>> as a scroll gesture. The scene tries to ensure that all the scroll events 
>> generated by the gesture are fired at the same target to ensure that the 
>> gesture's scroll events don't get split between two ScrollPanes. For 
>> example, while a ScrollPane is being scrolled a child ScrollPane might shift 
>> until it's beneath the mouse pointer. Scroll events should not fire at the 
>> child but remain with the parent.
>> 
>> During the gesture the scene should target the node that's handling the 
>> scrolling (like a ScrollPane) but there's no good way to determine that. 
>> Instead it targets a descendant node, whatever was under the mouse pointer 
>> when the gesture started. This node is likely to shift during the scroll and 
>> if scrolls out of view it might get disconnected from the scene graph. At 
>> that point events fired at it will go nowhere and the gesture will abruptly 
>> stop.
>> 
>> This PR detects when the gesture target is removed from the scene graph and 
>> attempts to find a new target.
>> 
>> This bug does not reproduce on Windows since that platform doesn't generate 
>> a SCROLL_STARTED event so the Scene never selects a gesture target. All 
>> scroll events are delivered to whatever node is under the mouse pointer 
>> which will change as the scroll progresses.
>> 
>> This PR might fix [JDK-8088460](https://bugs.openjdk.org/browse/JDK-8088460) 
>> which shows up in Ensemble if anyone wants to test that.
>> 
>> Submitting fix for sanity checking and manual testing. Will investigate 
>> creating an automated test for this.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Martin Fox has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Consistent handling of null pick node.

Code looks good and reasonable.
Just tested the fix together with a friend on his Mac (v26.5.1). 
Looks good and you can clearly see the broken scrolling before and the smooth 
scrolling after.

modules/javafx.graphics/src/main/java/javafx/scene/Scene.java line 2014:

> 2012:         if (gesture.target != null && (!gesture.finished || 
> e.isInertia())) {
> 2013:             pickedTarget = gesture.target.get();
> 2014:             if (pickedTarget instanceof Node) {

Minor suggestion

Suggestion:

            if (pickedTarget instanceof Node node) {

-------------

Marked as reviewed by mhanl (Committer).

PR Review: https://git.openjdk.org/jfx/pull/2171#pullrequestreview-4532247014
PR Review Comment: https://git.openjdk.org/jfx/pull/2171#discussion_r3441983796

Reply via email to