Skip to content

Commit cd12209

Browse files
Fix drag event jitter in Component.pointerDragged by using current coordinates
The existing logic in Component.pointerDragged scheduled a callSerially runnable to ensure drag events continue (e.g. for auto-scrolling) even if the pointer is stationary. However, it captured the `x` and `y` arguments from the method call. If multiple drag events occurred rapidly, these scheduled tasks would execute out of order relative to the latest system events, calling pointerDragged with stale coordinates. This caused the drag position to "jump back" to a previous location, resulting in visual jitter and incorrect drag direction detection. This fix updates the runnable to use `oldx` and `oldy` (instance fields tracking the latest processed drag position) instead of the captured arguments. This ensures that when the delayed task executes, it uses the most up-to-date position, effectively preventing the replay of stale coordinates.
1 parent 0286dde commit cd12209

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

CodenameOne/src/com/codename1/ui/Component.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5083,7 +5083,7 @@ private void pointerDragged(final Component lead, final int x, final int y, fina
50835083
Display.getInstance().callSerially(new Runnable() {
50845084
public void run() {
50855085
if (dragActivated) {
5086-
lead.pointerDragged(x, y, currentPointerPress);
5086+
lead.pointerDragged(oldx, oldy, currentPointerPress);
50875087
}
50885088
dragCallbacks--;
50895089
}

0 commit comments

Comments
 (0)