home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1995-04-21 | 34.2 KB | 1,265 lines
# This file is a Tcl script to test out Tk's "bind" and "bindtags" # commands plus the procedures in tkBind.c. It is organized in the # standard fashion for Tcl tests. # # Copyright (c) 1994 The Regents of the University of California. # Copyright (c) 1994 Sun Microsystems, Inc. # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # @(#) bind.test 1.17 95/04/21 14:08:02 if {[info commands testevent] == {}} { puts "This application hasn't been compiled with the \"testevent\"" puts "command, so I can't run this test. Are you sure you're using" puts "tktest instead of wish?" return } if {[string compare test [info procs test]] != 0} { source defs } catch {destroy .b} toplevel .b -width 100 -height 50 wm geom .b +0+0 update idletasks proc setup {} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 pack .b.f focus -force .b.f update } foreach i [bind Test] { bind Test $i {} } foreach i [bind all] { bind all $i {} } test bind-1.1 {bind command} { list [catch {bind} msg] $msg } {1 {wrong # args: should be "bind window ?pattern? ?command?"}} test bind-1.2 {bind command} { list [catch {bind a b c d} msg] $msg } {1 {wrong # args: should be "bind window ?pattern? ?command?"}} test bind-1.3 {bind command} { list [catch {bind .gorp} msg] $msg } {1 {bad window path name ".gorp"}} test bind-1.4 {bind command} { list [catch {bind foo} msg] $msg } {0 {}} test bind-1.5 {bind command} { list [catch {bind .b <gorp-> {}} msg] $msg } {0 {}} test bind-1.6 {bind command} { catch {destroy .b.f} frame .b.f bind .b.f <Enter> {test script} set result [bind .b.f <Enter>] bind .b.f <Enter> {} list $result [bind .b.f <Enter>] } {{test script} {}} test bind-1.7 {bind command} { catch {destroy .b.f} frame .b.f bind .b.f <Enter> {test script} bind .b.f <Enter> {+more text} bind .b.f <Enter> } {test script more text} test bind-1.8 {bind command} { list [catch {bind .b <gorp-> {test script}} msg] $msg [bind .b] } {1 {bad event type or keysym "gorp"} {}} test bind-1.9 {bind command} { list [catch {bind .b <gorp->} msg] $msg } {0 {}} test bind-1.10 {bind command} { catch {destroy .b.f} frame .b.f bind .b.f <Enter> {script 1} bind .b.f <Leave> {script 2} bind .b.f a {script for a} bind .b.f b {script for b} lsort [bind .b.f] } {<Enter> <Leave> a b} test bind-2.1 {bindtags command} { list [catch {bindtags} msg] $msg } {1 {wrong # args: should be "bindtags window ?tags?"}} test bind-2.2 {bindtags command} { list [catch {bindtags a b c} msg] $msg } {1 {wrong # args: should be "bindtags window ?tags?"}} test bind-2.3 {bindtags command} { list [catch {bindtags .foo} msg] $msg } {1 {bad window path name ".foo"}} test bind-2.4 {bindtags command} { bindtags .b } {.b Toplevel all} test bind-2.5 {bindtags command} { catch {destroy .b.f} frame .b.f bindtags .b.f } {.b.f Frame .b all} test bind-2.6 {bindtags command} { catch {destroy .b.f} frame .b.f bindtags .b.f {{x y z} b c d} bindtags .b.f } {{x y z} b c d} test bind-2.7 {bindtags command} { catch {destroy .b.f} frame .b.f bindtags .b.f {x y z} bindtags .b.f {} bindtags .b.f } {.b.f Frame .b all} test bind-2.8 {bindtags command} { catch {destroy .b.f} frame .b.f bindtags .b.f {x y z} bindtags .b.f {a b c d} bindtags .b.f } {a b c d} test bind-2.9 {bindtags command} { catch {destroy .b.f} frame .b.f bindtags .b.f {a b c} list [catch {bindtags .b.f "\{"} msg] $msg [bindtags .b.f] } {1 {unmatched open brace in list} {.b.f Frame .b all}} test bind-2.10 {bindtags command} { catch {destroy .b.f} frame .b.f bindtags .b.f {a b c} list [catch {bindtags .b.f "a .gorp b"} msg] $msg [bindtags .b.f] } {0 {} {a .gorp b}} test bind-3.1 {TkFreeBindingTags procedure} { catch {destroy .b.f} frame .b.f bindtags .b.f "a b c d" destroy .b.f } {} test bind-3.2 {TkFreeBindingTags procedure} { catch {destroy .b.f} frame .b.f catch {bindtags .b.f "a .gorp b .b.f"} destroy .b.f } {} bind all <Enter> {lappend x "%W enter all"} bind Test <Enter> {lappend x "%W enter frame"} bind Toplevel <Enter> {lappend x "%W enter toplevel"} bind xyz <Enter> {lappend x "%W enter xyz"} bind {a b} <Enter> {lappend x "%W enter {a b}"} bind .b <Enter> {lappend x "%W enter .b"} test bind-4.1 {TkBindEventProc procedure} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 pack .b.f update bind .b.f <Enter> {lappend x "%W enter .b.f"} set x {} testevent .b.f Enter set x } {{.b.f enter .b.f} {.b.f enter frame} {.b.f enter .b} {.b.f enter all}} test bind-4.2 {TkBindEventProc procedure} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 pack .b.f update bind .b.f <Enter> {lappend x "%W enter .b.f"} bindtags .b.f {.b.f {a b} xyz} set x {} testevent .b.f Enter set x } {{.b.f enter .b.f} {.b.f enter {a b}} {.b.f enter xyz}} test bind-4.3 {TkBindEventProc procedure} { set x {} testevent .b Enter set x } {{.b enter .b} {.b enter toplevel} {.b enter all}} test bind-4.4 {TkBindEventProc procedure} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 pack .b.f update bindtags .b.f {.b.f .b.f2 .b.f3} frame .b.f3 -width 50 -height 50 pack .b.f3 bind .b.f <Enter> {lappend x "%W enter .b.f"} bind .b.f3 <Enter> {lappend x "%W enter .b.f3"} set x {} testevent .b.f Enter destroy .b.f3 set x } {{.b.f enter .b.f} {.b.f enter .b.f3}} test bind-4.5 {TkBindEventProc procedure} { # This tests memory allocation for objPtr; it won't serve any useful # purpose unless run with some sort of allocation checker turned on. catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 pack .b.f update bindtags .b.f {a b c d e f g h i j k l m n o p q r s t u v w x y z} testevent .b.f Enter } {} bind all <Enter> {} bind Test <Enter> {} bind Toplevel <Enter> {} bind xyz <Enter> {} bind {a b} <Enter> {} bind .b <Enter> {} test bind-5.1 {Tk_CreateBindingTable procedure} { catch {destroy .b.c} canvas .b.c .b.c bind foo } {} test bind-6.1 { Tk_DeleteBindTable procedure} { catch {destroy .b.c} canvas .b.c .b.c bind foo <1> {string 1} .b.c create rectangle 0 0 100 100 .b.c bind 1 <2> {string 2} destroy .b.c } {} test bind-7.1 {Tk_CreateBinding procedure} { catch {destroy .b.c} canvas .b.c list [catch {.b.c bind foo <} msg] $msg } {1 {no event type or button # or keysym}} test bind-7.2 {Tk_CreateBinding procedure} { catch {destroy .b.c} canvas .b.c .b.c bind foo <1> "button 1" .b.c bind foo <1> "+more button 1" .b.c bind foo <1> } {button 1 more button 1} test bind-7.3 {Tk_CreateBinding procedure} { catch {destroy .b.c} canvas .b.c .b.c bind foo <1> "+button 1" .b.c bind foo <1> } {button 1} test bind-8.1 {Tk_DeleteBinding procedure} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 list [catch {bind .b.f <} msg] $msg } {0 {}} test bind-8.2 {Tk_DeleteBinding procedure} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 foreach i {a b c d} { bind .b.f $i "binding for $i" } set result {} foreach i {b d a c} { bind .b.f $i {} lappend result [lsort [bind .b.f]] } set result } {{a c d} {a c} c {}} test bind-8.3 {Tk_DeleteBinding procedure} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 foreach i {<1> <Meta-1> <Control-1> <Double-Alt-1>} { bind .b.f $i "binding for $i" } set result {} foreach i {<Control-1> <Double-Alt-1> <1> <Meta-1>} { bind .b.f $i {} lappend result [lsort [bind .b.f]] } set result } {{<Button-1> <Double-Alt-Button-1> <Meta-Button-1>} {<Button-1> <Meta-Button-1>} <Meta-Button-1> {}} test bind-9.1 {Tk_GetBinding procedure} { catch {destroy .b.c} canvas .b.c list [catch {.b.c bind foo <} msg] $msg } {1 {no event type or button # or keysym}} test bind-9.2 {Tk_GetBinding procedure} { catch {destroy .b.c} canvas .b.c .b.c bind foo a Test .b.c bind foo a } {Test} test bind-10.1 {Tk_GetAllBindings procedure} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 foreach i "! a \\\{ ~ <Delete> <space> <Tab> <Linefeed> <less> <Meta-a> <Acircumflex>" { bind .b.f $i Test } lsort [bind .b.f] } {! <Key-Acircumflex> <Key-Delete> <Key-Linefeed> <Key-Tab> <Key-less> <Key-space> <Meta-Key-a> a \{ ~} test bind-10.2 {Tk_GetAllBindings procedure} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 foreach i "<Double-1> <Triple-1> <Meta-Control-a> <Double-Alt-Enter> <1>" { bind .b.f $i Test } lsort [bind .b.f] } {<Button-1> <Control-Meta-Key-a> <Double-Alt-Enter> <Double-Button-1> <Triple-Button-1>} test bind-10.3 {Tk_GetAllBindings procedure} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 foreach i "<Double-Triple-1> abcd a<Leave>b" { bind .b.f $i Test } lsort [bind .b.f] } {<Triple-Button-1> a<Leave>b abcd} test bind-11.1 {Tk_DeleteAllBindings procedure} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 destroy .b.f } {} test bind-11.2 {Tk_DeleteAllBindings procedure} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 foreach i "a b c <Meta-1> <Alt-a> <Control-a>" { bind .b.f $i x } destroy .b.f } {} bind Test <KeyPress> {lappend x "%W %K Test press any"} bind all <KeyPress> {lappend x "%W %K all press any"} bind Test a {lappend x "%W %K Test press a"} bind all x {lappend x "%W %K all press x"} test bind-12.1 {Tk_BindEvent procedure} { setup bind .b.f a {lappend x "%W %K .b.f press a"} set x {} testevent .b.f KeyPress -keysym a testevent .b.f KeyPress -keysym b testevent .b.f KeyPress -keysym x set x } {{.b.f a .b.f press a} {.b.f a Test press a} {.b.f a all press any} {.b.f b Test press any} {.b.f b all press any} {.b.f x Test press any} {.b.f x all press x}} bind Test <KeyPress> {lappend x "%W %K Test press any"; break} bind all <KeyPress> {continue; lappend x "%W %K all press any"} test bind-12.2 {Tk_BindEvent procedure} { setup bind .b.f b {lappend x "%W %K .b.f press a"} set x {} testevent .b.f KeyPress -keysym b set x } {{.b.f b .b.f press a} {.b.f b Test press any}} if {[info procs tkerror] == "tkerror"} { rename tkerror {} } proc tkerror args {} bind Test <KeyPress> {lappend x "%W %K Test press any"; error Test} test bind-12.3 {Tk_BindEvent procedure} { setup bind .b.f b {lappend x "%W %K .b.f press a"} set x {} testevent .b.f KeyPress -keysym b update list $x $errorInfo } {{{.b.f b .b.f press a} {.b.f b Test press any}} {Test while executing "error Test" (command bound to event)}} rename tkerror {} test bind-12.4 {Tk_BindEvent procedure} { proc foo {} { set x 44 testevent .b.f KeyPress -keysym a } setup bind .b.f a {lappend x "%W %K .b.f press a"} set x {} foo set x } {{.b.f a .b.f press a} {.b.f a Test press a}} test bind-12.5 {Tk_BindEvent procedure} { bind all <Destroy> {lappend x "%W destroyed"} set x {} list [catch {frame .b.g -gorp foo} msg] $msg $x } {1 {unknown option "-gorp"} {{.b.g destroyed}}} foreach i [bind all] { bind all $i {} } foreach i [bind Test] { bind all $i {} } test bind-12.6 {Tk_BindEvent procedure} { setup bind .b.f z {lappend x "%W z (.b.f binding)"} bind Test z {lappend x "%W z (.b.f binding)"} bind all z {bind .b.f z {}; lappend x "%W z (.b.f binding)"} set x {} testevent .b.f KeyPress -keysym z set x } {{.b.f z (.b.f binding)} {.b.f z (.b.f binding)} {.b.f z (.b.f binding)}} test bind-12.7 {Tk_BindEvent procedure} { setup bind .b.f z {lappend x "%W z (.b.f binding)"} bind Test z {lappend x "%W z (.b.f binding)"} bind all z {destroy .b.f; lappend x "%W z (.b.f binding)"} set x {} testevent .b.f KeyPress -keysym z set x } {{.b.f z (.b.f binding)} {.b.f z (.b.f binding)} {.b.f z (.b.f binding)}} test bind-12.8 {Tk_BindEvent procedure} { setup bind .b.f <1> {lappend x "%W z (.b.f <1> binding)"} bind .b.f <ButtonPress> {lappend x "%W z (.b.f <ButtonPress> binding)"} set x {} testevent .b.f ButtonPress -button 1 testevent .b.f ButtonPress -button 2 set x } {{.b.f z (.b.f <1> binding)} {.b.f z (.b.f <ButtonPress> binding)}} test bind-13.1 {FindSequence procedure} { list [catch {bind .b {} test} msg] $msg } {1 {no events specified in binding}} test bind-13.2 {FindSequence procedure} { list [catch {bind .b \x7 test} msg] $msg } {1 {bad ASCII character 0x7}} test bind-13.3 {FindSequence procedure} { list [catch {bind .b "\x7f" test} msg] $msg } {1 {bad ASCII character 0x7f}} test bind-13.4 {FindSequence procedure} { list [catch {bind .b "\xc4" test} msg] $msg } {1 {bad ASCII character 0xc4}} test bind-13.5 {FindSequence procedure} { list [catch {bind .b <> test} msg] $msg } {1 {no event type or button # or keysym}} test bind-13.6 {FindSequence procedure} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 bind .b.f <a---> {nothing} bind .b.f } a test bind-13.7 {FindSequence procedure} { list [catch {bind .b <a-- test} msg] $msg } {1 {missing ">" in binding}} test bind-13.8 {FindSequence procedure, multiple bindings} { setup bind .b.f <1> {lappend x single} bind .b.f <Double-1> {lappend x double} bind .b.f <Triple-1> {lappend x triple} set x press testevent .b.f ButtonPress -button 1 lappend x press testevent .b.f ButtonPress -button 1 lappend x press testevent .b.f ButtonPress -button 1 lappend x press testevent .b.f ButtonPress -button 1 set x } {press single press double press triple press triple} set i 1 foreach check { {{<Control- a>} <Control-Key-a>} {<Shift-a> <Shift-Key-a>} {<Lock-a> <Lock-Key-a>} {<Meta---a> <Meta-Key-a>} {<M-a> <Meta-Key-a>} {<Alt-a> <Alt-Key-a>} {<B1-a> <B1-Key-a>} {<B2-a> <B2-Key-a>} {<B3-a> <B3-Key-a>} {<B4-a> <B4-Key-a>} {<B5-a> <B5-Key-a>} {<Button1-a> <B1-Key-a>} {<Button2-a> <B2-Key-a>} {<Button3-a> <B3-Key-a>} {<Button4-a> <B4-Key-a>} {<Button5-a> <B5-Key-a>} {<M1-a> <Mod1-Key-a>} {<M2-a> <Mod2-Key-a>} {<M3-a> <Mod3-Key-a>} {<M4-a> <Mod4-Key-a>} {<M5-a> <Mod5-Key-a>} {<Mod1-a> <Mod1-Key-a>} {<Mod2-a> <Mod2-Key-a>} {<Mod3-a> <Mod3-Key-a>} {<Mod4-a> <Mod4-Key-a>} {<Mod5-a> <Mod5-Key-a>} {<Double-a> aa} {<Triple-a> aaa} {{<Double 1>} <Double-Button-1>} {<Triple-1> <Triple-Button-1>} {{<M1-M2 M3-M4 B1-Control-a>} <Control-B1-Mod1-Mod2-Mod3-Mod4-Key-a>} } { test bind-13.$i {modifier names} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 bind .b.f [lindex $check 0] foo bind .b.f } [lindex $check 1] bind .b.f [lindex $check 1] {} incr i } foreach event [bind Test] { bind Test $event {} } foreach event [bind all] { bind all $event {} } test bind-14.1 {event names} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 bind .b.f <FocusIn> {nothing} bind .b.f } <FocusIn> test bind-14.2 {event names} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 bind .b.f <FocusOut> {nothing} bind .b.f } <FocusOut> test bind-14.3 {event names} { setup bind .b.f <Destroy> {lappend x "destroyed"} set x [bind .b.f] destroy .b.f set x } {<Destroy> destroyed} set i 4 foreach check { {Motion Motion} {Button Button} {ButtonPress Button} {ButtonRelease ButtonRelease} {Colormap Colormap} {Enter Enter} {Leave Leave} {Expose Expose} {Key Key} {KeyPress Key} {KeyRelease KeyRelease} {Property Property} {Circulate Circulate} {Configure Configure} {Gravity Gravity} {Map Map} {Reparent Reparent} {Unmap Unmap} {Visibility Visibility} } { set event [lindex $check 0] test bind-14.$i {event names} { setup bind .b.f <$event> "set x \"event $event\"" set x xyzzy testevent .b.f $event -window .b.f list $x [bind .b.f] } [list "event $event" <[lindex $check 1]>] incr i } test bind-15.1 {button names} { list [catch {bind .b <Expose-1> foo} msg] $msg } {1 {specified button "1" for non-button event}} test bind-16.1 {button names} { list [catch {bind .b <Button-6> foo} msg] $msg } {1 {specified keysym "6" for non-key event}} set i 2 foreach button {1 2 3 4 5} { test bind-15.$i {button names} { setup bind .b.f <Button-$button> "lappend x \"button $button\"" set x [bind .b.f] testevent .b.f ButtonPress -button $button set x } [list <Button-$button> "button $button"] incr i } test bind-17.1 {keysym names} { list [catch {bind .b <Expose-a> foo} msg] $msg } {1 {specified keysym "a" for non-key event}} test bind-17.2 {keysym names} { list [catch {bind .b <Gorp> foo} msg] $msg } {1 {bad event type or keysym "Gorp"}} test bind-17.3 {keysym names} { list [catch {bind .b <Key-Stupid> foo} msg] $msg } {1 {bad event type or keysym "Stupid"}} test bind-17.4 {keysym names} { catch {destroy .b.f} frame .b.f -class Test -width 150 -height 100 bind .b.f <a> foo bind .b.f } a set i 5 foreach check { {a 0 a} {space 0 <Key-space>} {Return 0 <Key-Return>} {X 1 X} } { set keysym [lindex $check 0] test bind-16.$i {keysym names} { setup bind .b.f <Key-$keysym> "lappend x \"keysym $keysym\"" bind .b.f <Key-x> "lappend x {bad binding match}" set x [lsort [bind .b.f]] testevent .b.f Key -keysym $keysym -state [lindex $check 1] set x } [concat [lsort "x [lindex $check 2]"] "{keysym $keysym}"] incr i } if $doNonPortableTests { setup bind .b.f <KeyPress> {set x %K} set i 1 foreach check { {a 0 a} {x 1 X} {x 2 X} {space 0 space} {F1 1 F1} } { test bind-17.$i {GetKeySym procedure} { set x nothing testevent .b.f KeyPress -keysym [lindex $check 0] \ -state [lindex $check 1] set x } [lindex $check 2] incr i } } test bind-18.1 {MatchPatterns procedure, ignoring type mismatches} { setup bind .b.f ab {set x 1} set x 0 testevent .b.f Key -keysym a testevent .b.f KeyRelease -keysym a testevent .b.f Key -keysym b testevent .b.f KeyRelease -keysym b set x } 1 test bind-18.2 {MatchPatterns procedure, ignoring type mismatches} { setup bind .b.f ab {set x 1} set x 0 testevent .b.f Key -keysym a testevent .b.f Enter testevent .b.f KeyRelease -keysym a testevent .b.f Leave testevent .b.f Key -keysym b testevent .b.f KeyRelease -keysym b set x } 1 test bind-18.3 {MatchPatterns procedure, ignoring type mismatches} { setup bind .b.f ab {set x 1} set x 0 testevent .b.f Key -keysym a testevent .b.f ButtonPress -button 1 testevent .b.f Key -keysym b set x } 0 test bind-18.4 {MatchPatterns procedure, ignoring type mismatches} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f ButtonPress -button 1 testevent .b.f ButtonRelease -button 1 testevent .b.f ButtonPress -button 1 testevent .b.f ButtonRelease -button 1 set x } 1 test bind-18.5 {MatchPatterns procedure, ignoring type mismatches} { setup bind .b.f <Double-ButtonRelease> {set x 1} set x 0 testevent .b.f ButtonPress -button 1 testevent .b.f ButtonRelease -button 1 testevent .b.f ButtonPress -button 2 testevent .b.f ButtonRelease -button 2 set x } 1 test bind-18.6 {MatchPatterns procedure, ignoring type mismatches} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f ButtonPress -button 1 testevent .b.f Key -keysym a testevent .b.f ButtonRelease -button 1 testevent .b.f ButtonPress -button 1 testevent .b.f ButtonRelease -button 1 set x } 0 test bind-18.7 {MatchPatterns procedure, ignoring type mismatches} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f ButtonPress -button 1 testevent .b.f Key -keysym Shift_L testevent .b.f ButtonRelease -button 1 testevent .b.f ButtonPress -button 1 testevent .b.f ButtonRelease -button 1 set x } 1 test bind-18.8 {MatchPatterns procedure, ignoring type mismatches} { setup bind .b.f ab {set x 1} set x 0 testevent .b.f Key -keysym a testevent .b.f Key -keysym c testevent .b.f Key -keysym b set x } 0 test bind-18.9 {MatchPatterns procedure, modifier checks} { setup bind .b.f <M1-M2-Key> {set x 1} set x 0 testevent .b.f Key -keysym a -state 0x18 set x } 1 test bind-18.10 {MatchPatterns procedure, modifier checks} { setup bind .b.f <M1-M2-Key> {set x 1} set x 0 testevent .b.f Key -keysym a -state 0xfc set x } 1 test bind-18.11 {MatchPatterns procedure, modifier checks} { setup bind .b.f <M1-M2-Key> {set x 1} set x 0 testevent .b.f Key -keysym a -state 0x8 set x } 0 test bind-18.12 {MatchPatterns procedure, ignore modifier presses and releases} { setup bind .b.f aB {set x 1} set x 0 testevent .b.f Key -keysym a testevent .b.f Key -keysym Shift_L testevent .b.f Key -keysym b -state 1 set x } 1 test bind-18.13 {MatchPatterns procedure, checking detail} { setup bind .b.f ab {set x 1} set x 0 testevent .b.f Key -keysym a testevent .b.f Key -keysym c set x } 0 test bind-18.14 {MatchPatterns procedure, checking "nearby"} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f Button -button 1 -x 30 -y 40 testevent .b.f Button -button 1 -x 31 -y 39 set x } 1 test bind-18.15 {MatchPatterns procedure, checking "nearby"} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f Button -button 1 -x 30 -y 40 testevent .b.f Button -button 1 -x 29 -y 41 set x } 1 test bind-18.16 {MatchPatterns procedure, checking "nearby"} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f Button -button 1 -x 30 -y 40 testevent .b.f Button -button 1 -x 40 -y 40 set x } 0 test bind-18.17 {MatchPatterns procedure, checking "nearby"} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f Button -button 1 -x 30 -y 40 testevent .b.f Button -button 1 -x 20 -y 40 set x } 0 test bind-18.18 {MatchPatterns procedure, checking "nearby"} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f Button -button 1 -x 30 -y 40 testevent .b.f Button -button 1 -x 30 -y 30 set x } 0 test bind-18.19 {MatchPatterns procedure, checking "nearby"} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f Button -button 1 -x 30 -y 40 testevent .b.f Button -button 1 -x 30 -y 50 set x } 0 test bind-18.20 {MatchPatterns procedure, checking "nearby"} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f Button -button 1 -time 300 testevent .b.f Button -button 1 -time 700 set x } 1 test bind-18.21 {MatchPatterns procedure, checking "nearby"} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f Button -button 1 -time 300 testevent .b.f Button -button 1 -time 900 set x } 0 test bind-18.22 {MatchPatterns procedure, time wrap-around} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f Button -button 1 -time [expr -100] testevent .b.f Button -button 1 -time 200 set x } 1 test bind-18.23 {MatchPatterns procedure, time wrap-around} { setup bind .b.f <Double-1> {set x 1} set x 0 testevent .b.f Button -button 1 -time [expr -100] testevent .b.f Button -button 1 -time 500 set x } 0 test bind-18.24 {MatchPatterns procedure, conflict resolution} { setup bind .b.f <KeyPress> {set x 0} bind .b.f a {set x 1} set x none testevent .b.f Key -keysym a set x } 1 test bind-18.25 {MatchPatterns procedure, conflict resolution} { setup bind .b.f <KeyPress> {set x 0} bind .b.f a {set x 1} set x none testevent .b.f Key -keysym b set x } 0 test bind-18.26 {MatchPatterns procedure, conflict resolution} { setup bind .b.f <KeyPress> {lappend x 0} bind .b.f a {lappend x 1} bind .b.f ba {lappend x 2} set x none testevent .b.f Key -keysym b testevent .b.f KeyRelease -keysym b testevent .b.f Key -keysym a set x } {none 0 2} test bind-18.27 {MatchPatterns procedure, conflict resolution} { setup bind .b.f <ButtonPress> {set x 0} bind .b.f <1> {set x 1} set x none testevent .b.f Button -button 1 set x } 1 test bind-18.28 {MatchPatterns procedure, conflict resolution} { setup bind .b.f <M1-Key> {set x 0} bind .b.f <M2-Key> {set x 1} set x none testevent .b.f Key -keysym a -state 0x18 set x } 1 test bind-18.29 {MatchPatterns procedure, conflict resolution} { setup bind .b.f <M2-Key> {set x 0} bind .b.f <M1-Key> {set x 1} set x none testevent .b.f Key -keysym a -state 0x18 set x } 1 test bind-18.30 {MatchPatterns procedure, conflict resolution} { setup bind .b.f <1> {lappend x single} bind Test <1> {lappend x single(Test)} bind Test <Double-1> {lappend x double(Test)} set x {} testevent .b.f ButtonPress -button 1 testevent .b.f ButtonPress -button 1 testevent .b.f ButtonPress -button 1 set x } {single single(Test) single double(Test) single double(Test)} foreach i [bind Test] { bind Test $i {} } test bind-19.1 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x abcd} set x none testevent .b.f Enter set x } abcd test bind-19.2 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x %#} set x none testevent .b.f Enter -serial 1234 set x } 1234 test bind-19.3 {ExpandPercents procedure} { setup bind .b.f <Configure> {set x %a} set x none testevent .b.f Configure -above .b -window .b.f set x } [winfo id .b] test bind-19.4 {ExpandPercents procedure} { setup bind .b.f <Button> {set x %b} set x none testevent .b.f Button -button 3 set x } 3 test bind-19.5 {ExpandPercents procedure} { setup bind .b.f <Expose> {set x %c} set x none testevent .b.f Expose -count 47 set x } 47 test bind-19.6 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x %d} set x none testevent .b.f Enter -detail NotifyAncestor set x } NotifyAncestor test bind-19.7 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x %d} set x none testevent .b.f Enter -detail NotifyVirtual set x } NotifyVirtual test bind-19.8 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x %d} set x none testevent .b.f Enter -detail NotifyNonlinear set x } NotifyNonlinear test bind-19.9 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x %d} set x none testevent .b.f Enter -detail NotifyNonlinearVirtual set x } NotifyNonlinearVirtual test bind-19.10 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x %d} set x none testevent .b.f Enter -detail NotifyPointer set x } NotifyPointer test bind-19.11 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x %d} set x none testevent .b.f Enter -detail NotifyPointerRoot set x } NotifyPointerRoot test bind-19.12 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x %d} set x none testevent .b.f Enter -detail NotifyDetailNone set x } NotifyDetailNone test bind-19.13 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x %f} set x none testevent .b.f Enter -focus 1 set x } 1 test bind-19.14 {ExpandPercents procedure} { setup bind .b.f <Expose> {set x "%x %y %w %h"} set x none testevent .b.f Expose -x 24 -y 18 -width 147 -height 61 set x } {24 18 147 61} test bind-19.15 {ExpandPercents procedure} { setup bind .b.f <Configure> {set x "%x %y %w %h"} set x none testevent .b.f Configure -x 24 -y 18 -width 147 -height 61 -window .b.f set x } {24 18 147 61} test bind-19.16 {ExpandPercents procedure} { setup bind .b.f <Key> {set x "%k"} set x none testevent .b.f Key -keycode 146 set x } 146 test bind-19.17 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x "%m"} set x none testevent .b.f Enter -mode NotifyNormal set x } NotifyNormal test bind-19.18 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x "%m"} set x none testevent .b.f Enter -mode NotifyGrab set x } NotifyGrab test bind-19.19 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x "%m"} set x none testevent .b.f Enter -mode NotifyUngrab set x } NotifyUngrab test bind-19.20 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x "%m"} set x none testevent .b.f Enter -mode NotifyWhileGrabbed set x } NotifyWhileGrabbed test bind-19.21 {ExpandPercents procedure} { setup bind .b.f <Map> {set x "%o"} set x none testevent .b.f Map -override 1 -window .b.f set x } 1 test bind-19.22 {ExpandPercents procedure} { setup bind .b.f <Reparent> {set x "%o"} set x none testevent .b.f Reparent -override 13 -window .b.f set x } 13 test bind-19.23 {ExpandPercents procedure} { setup bind .b.f <Configure> {set x "%o"} set x none testevent .b.f Configure -override 2 -window .b.f set x } 2 test bind-19.24 {ExpandPercents procedure} { setup bind .b.f <Circulate> {set x "%p"} set x none testevent .b.f Circulate -place PlaceOnTop -window .b.f set x } PlaceOnTop test bind-19.25 {ExpandPercents procedure} { setup bind .b.f <Circulate> {set x "%p"} set x none testevent .b.f Circulate -place PlaceOnBottom -window .b.f set x } PlaceOnBottom test bind-19.26 {ExpandPercents procedure} { setup bind .b.f <Circulate> {set x "%p"} set x none testevent .b.f Circulate -place bogus -window .b.f set x } ?? test bind-19.27 {ExpandPercents procedure} { setup bind .b.f <1> {set x "%s"} set x none testevent .b.f Button -button 1 -state 122 set x } 122 test bind-19.28 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x "%s"} set x none testevent .b.f Enter -state 0x3ff set x } 1023 test bind-19.29 {ExpandPercents procedure} { setup bind .b.f <Visibility> {set x "%s"} set x none testevent .b.f Visibility -state VisibilityPartiallyObscured set x } VisibilityPartiallyObscured test bind-19.30 {ExpandPercents procedure} { setup bind .b.f <Visibility> {set x "%s"} set x none testevent .b.f Visibility -state VisibilityUnobscured set x } VisibilityUnobscured test bind-19.31 {ExpandPercents procedure} { setup bind .b.f <Visibility> {set x "%s"} set x none testevent .b.f Visibility -state VisibilityFullyObscured set x } VisibilityFullyObscured test bind-19.32 {ExpandPercents procedure} { setup bind .b.f <Button> {set x "%t"} set x none testevent .b.f Button -time 4294 set x } 4294 test bind-19.33 {ExpandPercents procedure} { setup bind .b.f <Button> {set x "%x %y"} set x none testevent .b.f Button -x 881 -y 432 set x } {881 432} test bind-19.34 {ExpandPercents procedure} { setup bind .b.f <Reparent> {set x "%x %y"} set x none testevent .b.f Reparent -x 882 -y 431 -window .b.f set x } {882 431} test bind-19.35 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x "%x %y"} set x none testevent .b.f Enter -x 781 -y 632 set x } {781 632} if $doNonPortableTests { test bind-19.36 {ExpandPercents procedure} { setup bind .b.f <Key> {lappend x "%A"} set x {} testevent .b.f Key -keysym a testevent .b.f Key -keysym A -state 1 testevent .b.f Key -keysym Tab testevent .b.f Key -keysym Return testevent .b.f Key -keysym F1 testevent .b.f Key -keysym Shift_L testevent .b.f Key -keysym space testevent .b.f Key -keysym dollar -state 1 testevent .b.f Key -keysym braceleft -state 1 set x } "a A { } {\r} {{}} {{}} { } {\$} \\\{" } test bind-19.37 {ExpandPercents procedure} { setup bind .b.f <Configure> {set x "%B"} set x none testevent .b.f Configure -borderwidth 24 -window .b.f set x } 24 test bind-19.38 {ExpandPercents procedure} { setup bind .b.f <Enter> {set x "%E"} set x none testevent .b.f Enter -sendevent 1 set x } 1 if $doNonPortableTests { test bind-19.39 {ExpandPercents procedure} { setup bind .b.f <Key> {lappend x %K} set x {} testevent .b.f Key -keysym a testevent .b.f Key -keysym A -state 1 testevent .b.f Key -keysym Tab testevent .b.f Key -keysym F1 testevent .b.f Key -keysym Shift_L testevent .b.f Key -keysym space testevent .b.f Key -keysym dollar -state 1 testevent .b.f Key -keysym braceleft -state 1 set x } {a A Tab F1 Shift_L space dollar braceleft} } test bind-19.40 {ExpandPercents procedure} { setup bind .b.f <Key> {set x "%N"} set x none testevent .b.f Key -keysym a set x } 97 test bind-19.41 {ExpandPercents procedure} { setup bind .b.f <Key> {set x "%S"} set x none testevent .b.f Key -keysym a -subwindow .b set x } [winfo id .b] test bind-19.42 {ExpandPercents procedure} { setup bind .b.f <Key> {set x "%T"} set x none testevent .b.f Key set x } 2 test bind-19.43 {ExpandPercents procedure} { setup bind .b.f <Key> {set x "%W"} set x none testevent .b.f Key set x } .b.f test bind-19.44 {ExpandPercents procedure} { setup bind .b.f <Button> {set x "%X %Y"} set x none testevent .b.f Button -rootx 422 -rooty 13 set x } {422 13} proc tkerror msg { global x errorInfo set x [list $msg $errorInfo] } test bind-20.1 {Tk_BackgroundError procedure} { setup bind .b.f <Button> {error "This is a test"} set x none testevent .b.f Button update set x } {{This is a test} {This is a test while executing "error "This is a test"" (command bound to event)}} test bind-20.2 {Tk_BackgroundError procedure} { proc do {} { testevent .b.f Button } setup bind .b.f <Button> {error Message2} set x none do update set x } {Message2 {Message2 while executing "error Message2" (command bound to event)}} rename tkerror {} destroy .b