Artifact
19525dff83ed70a20bec865e9ef302f722ff0ac8de917ddbfad4beef3f1987c2:
Attachment "exercise.tcl" to
ticket [e3888d58]
added by
erikleunissen
2020-01-04 16:07:03.
(unpublished)
#! /usr/bin/tclsh
#
# Usage: exercise.tcl doGrab warpPrologue
#
if {[llength $argv] > 0} {
set doGrab [lindex $argv 0]
}
if {! [info exists doGrab]} {
set doGrab 1
}
if {[llength $argv] > 1} {
set warpPrologue [lindex $argv 1]
}
if {! [info exists warpPrologue]} {
set warpPrologue 0
}
#
# Wait for a specified duration while allowing events to be processed
#
proc twait {duration} {
set ::_twait 1; after $duration {unset ::_twait}
vwait ::_twait
}
# prologue
package require Tk
wm withdraw .; # not special
toplevel .t
wm geometry .t 200x200+300+300
pack [label .t.l -height 5 -width 20 -highlightthickness 2 -highlightbackground black -bg yellow -text " "] -side bottom
wm deiconify .t
twait 2000
if {$warpPrologue} {
event generate .t <Motion> -warp 1 -x -50 -y 50
twait 1000
event generate .t <Motion> -warp 1 -x +50 -y 50
twait 1000
}
event generate .t <Motion> -warp 1 -x -50 -y 50
twait 1000
if {$doGrab} {
#
# Change of background just allows visual recognition of timing
#
.t configure -bg #FF9999; grab .t; # *** grab makes the mouse pointer to become stuck
twait 1000; # allow time for screen updates
}
event generate .t.l <Motion> -warp 1 -x 10 -y 10
twait 1000
exit
# EOF