Version 11 of warp

Updated 2012-09-02 14:10:41 by RLE

The standard reference for "pointer warping" for Tk has been the "usage FAQ" [L1 ] (2004-12-19: link dead) [oooo; we do need to fix that link ...]. 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).

Another legitimate use of pointer warping was the GUI design of Interleaf Version <= 5. The GUI was mainly context-menu driven and remembered the last menu choice in the cascading tree of sub-menus. With a delay of about 300ms, the next cascade opened with mouse pointer on appropriate entry. It was not the worst GUI I've worked with. (wdb)


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".