mouse-xcor1.0 mouse-ycor1.0

mouse-xcor mouse-ycor

Reports the x or y coordinate of the mouse in the 2D view. The value is in terms of turtle coordinates, so it might not be an integer. If you want patch coordinates, use round mouse-xcor and round mouse-ycor.

Note: If the mouse is outside of the 2D view, reports the value from the last time it was inside.

;; to make the mouse "draw" in red:
if mouse-down?
  [ ask patch mouse-xcor mouse-ycor [ set pcolor red ] ]

Take me to the full NetLogo Dictionary