Version 8 of warp

Updated 2006-05-05 20:57:40

The standard reference for "pointer warping" for Tk has been the "usage FAQ" [L1 ] (2004-12-19: link dead). It briefly mentions that pointer warping is a bad idea (don't do that), supplies source for an extension which implements warping, and also points to [fill in the details here ...], with its implementation of the same as ... The FAQ doesn't seem to be current ...

As "Changes in Tcl/Tk 8.3" hints, release 8.3's event command builds in pointer warping.

Here is a simple example of pointer warping:

 event generate . <Motion> -warp 1 -x 50 -y 50.

(Move the cursor to the '.' window, inset 50 pixels from top left corner)

Among the legitimate uses of pointer warping are test automations, including Android, and for pedagogic purposes (Android can also help build demonstrations).


kroc - Here's a trick to move the mouse cursor with keyboard arrows. It could be useful when mouse is broken. Someone should add mouse click with spacebar or enter.

 bind . <Up> { event generate . <Motion> -warp 1 -x [expr %x+0] -y [expr %y-10] }
 bind . <Down> { event generate . <Motion> -warp 1 -x [expr %x+0] -y [expr %y+10] }
 bind . <Left> { event generate . <Motion> -warp 1 -x [expr %x-10] -y [expr %y+0] }
 bind . <Right> { event generate . <Motion> -warp 1 -x [expr %x+10] -y [expr %y+0] }

Also see "Moving the mouse".