Mouse position is tracked beyond sketch window while dragging

This is not a question but a statement.
According to the reference, Processing can only track mouseX and mouseY when the pointer is over the current window. Once the mouse moves away from the window, mouseX and mouseY will continue to report their most recent position.
I’ve found that while dragging away from the window, mouseX and mouseY will continue to report their current position.

This simple code can demonstrate the difference between moving away and dragging away from the window:

void draw() {
  background(204);
  line(width/2, height/2, mouseX, mouseY);
}

2 Likes