/
bind.test
6062 lines (5786 loc) · 164 KB
/
bind.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# 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-1995 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
package require tcltest 2.2
namespace import ::tcltest::*
eval tcltest::configure $argv
tcltest::loadTestedCommands
tk useinputmethods 0
toplevel .t -width 100 -height 50
wm geom .t +0+0
update idletasks
foreach p [event info] {event delete $p}
foreach event [bind Test] {
bind Test $event {}
}
foreach event [bind all] {
bind all $event {}
}
proc unsetBindings {} {
bind all <Enter> {}
bind Test <Enter> {}
bind Toplevel <Enter> {}
bind xyz <Enter> {}
bind {a b} <Enter> {}
bind .t <Enter> {}
}
test bind-1.1 {bind command} -body {
bind
} -returnCodes error -result {wrong # args: should be "bind window ?pattern? ?command?"}
test bind-1.2 {bind command} -body {
bind a b c d
} -returnCodes error -result {wrong # args: should be "bind window ?pattern? ?command?"}
test bind-1.3 {bind command} -body {
bind .gorp
} -returnCodes error -result {bad window path name ".gorp"}
test bind-1.4 {bind command} -body {
bind foo
} -returnCodes ok -result {}
test bind-1.5 {bind command} -body {
bind .t <gorp-> {}
} -returnCodes ok -result {}
test bind-1.6 {bind command} -body {
frame .t.f
bind .t.f <Enter> {test script}
set result [bind .t.f <Enter>]
bind .t.f <Enter> {}
list $result [bind .t.f <Enter>]
} -cleanup {
destroy .t.f
} -result {{test script} {}}
test bind-1.7 {bind command} -body {
frame .t.f
bind .t.f <Enter> {test script}
bind .t.f <Enter> {+more text}
bind .t.f <Enter>
} -cleanup {
destroy .t.f
} -result {test script
more text}
test bind-1.8 {bind command} -body {
bind .t <gorp-> {test script}
} -returnCodes error -result {bad event type or keysym "gorp"}
test bind-1.9 {bind command} -body {
catch {bind .t <gorp-> {test script}}
bind .t
} -result {}
test bind-1.10 {bind command} -body {
bind .t <gorp->
} -returnCodes ok -result {}
test bind-1.11 {bind command} -body {
frame .t.f
bind .t.f <Enter> {script 1}
bind .t.f <Leave> {script 2}
bind .t.f a {script for a}
bind .t.f b {script for b}
lsort [bind .t.f]
} -cleanup {
destroy .t.f
} -result {<Enter> <Leave> a b}
test bind-2.1 {bindtags command} -body {
bindtags
} -returnCodes error -result {wrong # args: should be "bindtags window ?taglist?"}
test bind-2.2 {bindtags command} -body {
bindtags a b c
} -returnCodes error -result {wrong # args: should be "bindtags window ?taglist?"}
test bind-2.3 {bindtags command} -body {
bindtags .foo
} -returnCodes error -result {bad window path name ".foo"}
test bind-2.4 {bindtags command} -body {
bindtags .t
} -result {.t Toplevel all}
test bind-2.5 {bindtags command} -body {
frame .t.f
bindtags .t.f
} -cleanup {
destroy .t.f
} -result {.t.f Frame .t all}
test bind-2.6 {bindtags command} -body {
frame .t.f
bindtags .t.f {{x y z} b c d}
bindtags .t.f
} -cleanup {
destroy .t.f
} -result {{x y z} b c d}
test bind-2.7 {bindtags command} -body {
frame .t.f
bindtags .t.f {x y z}
bindtags .t.f {}
bindtags .t.f
} -cleanup {
destroy .t.f
} -result {.t.f Frame .t all}
test bind-2.8 {bindtags command} -body {
frame .t.f
bindtags .t.f {x y z}
bindtags .t.f {a b c d}
bindtags .t.f
} -cleanup {
destroy .t.f
} -result {a b c d}
test bind-2.9 {bindtags command} -body {
frame .t.f
bindtags .t.f {a b c}
bindtags .t.f "\{"
} -cleanup {
destroy .t.f
} -returnCodes error -result {unmatched open brace in list}
test bind-2.10 {bindtags command} -body {
frame .t.f
bindtags .t.f {a b c}
catch {bindtags .t.f "\{"}
bindtags .t.f
} -cleanup {
destroy .t.f
} -result {.t.f Frame .t all}
test bind-2.11 {bindtags command} -body {
frame .t.f
bindtags .t.f {a b c}
bindtags .t.f "a .gorp b"
} -cleanup {
destroy .t.f
} -returnCodes ok
test bind-2.12 {bindtags command} -body {
frame .t.f
bindtags .t.f {a b c}
catch {bindtags .t.f "a .gorp b"}
bindtags .t.f
} -cleanup {
destroy .t.f
} -result {a .gorp b}
test bind-3.1 {TkFreeBindingTags procedure} -body {
frame .t.f
bindtags .t.f "a b c d"
destroy .t.f
} -cleanup {
destroy .t.f
} -result {}
test bind-3.2 {TkFreeBindingTags procedure} -body {
frame .t.f
catch {bindtags .t.f "a .gorp b .t.f"}
destroy .t.f
} -cleanup {
destroy .t.f
} -result {}
test bind-4.1 {TkBindEventProc procedure} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
update
set x {}
} -body {
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 .t <Enter> {lappend x "%W enter .t"}
bind .t.f <Enter> {lappend x "%W enter .t.f"}
event generate .t.f <Enter>
return $x
} -cleanup {
destroy .t.f
unsetBindings
} -result {{.t.f enter .t.f} {.t.f enter frame} {.t.f enter .t} {.t.f enter all}}
test bind-4.2 {TkBindEventProc procedure} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
update
set x {}
} -body {
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 .t <Enter> {lappend x "%W enter .t"}
bind .t.f <Enter> {lappend x "%W enter .t.f"}
bindtags .t.f {.t.f {a b} xyz}
event generate .t.f <Enter>
return $x
} -cleanup {
destroy .t.f
unsetBindings
} -result {{.t.f enter .t.f} {.t.f enter {a b}} {.t.f enter xyz}}
test bind-4.3 {TkBindEventProc procedure} -body {
set x {}
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 .t <Enter> {lappend x "%W enter .t"}
event generate .t <Enter>
return $x
} -cleanup {
unsetBindings
} -result {{.t enter .t} {.t enter toplevel} {.t enter all}}
test bind-4.4 {TkBindEventProc procedure} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
frame .t.f3 -width 50 -height 50
pack .t.f3
update
set x {}
} -body {
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 .t <Enter> {lappend x "%W enter .t"}
bindtags .t.f {.t.f .t.f2 .t.f3}
bind .t.f <Enter> {lappend x "%W enter .t.f"}
bind .t.f3 <Enter> {lappend x "%W enter .t.f3"}
event generate .t.f <Enter>
return $x
} -cleanup {
destroy .t.f .t.f3
unsetBindings
} -result {{.t.f enter .t.f} {.t.f enter .t.f3}}
test bind-4.5 {TkBindEventProc procedure} -setup {
# This tests memory allocation for objPtr; it won't serve any useful
# purpose unless run with some sort of allocation checker turned on.
frame .t.f -class Test -width 150 -height 100
pack .t.f
update
} -body {
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 .t <Enter> {lappend x "%W enter .t"}
bindtags .t.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}
event generate .t.f <Enter>
} -cleanup {
destroy .t.f
unsetBindings
} -result {}
test bind-5.1 {Tk_CreateBindingTable procedure} -body {
canvas .t.c
.t.c bind foo
} -cleanup {
destroy .t.c
} -result {}
test bind-6.1 {Tk_DeleteBindTable procedure} -body {
canvas .t.c
.t.c bind foo <1> {string 1}
.t.c create rectangle 0 0 100 100
.t.c bind 1 <2> {string 2}
destroy .t.c
} -cleanup {
destroy .t.c
} -result {}
test bind-7.1 {Tk_CreateBinding procedure: bad binding} -body {
canvas .t.c
.t.c bind foo <
} -cleanup {
destroy .t.c
} -returnCodes error -result {no event type or button # or keysym}
test bind-7.3 {Tk_CreateBinding procedure: append} -body {
canvas .t.c
.t.c bind foo <1> "button 1"
.t.c bind foo <1> "+more button 1"
.t.c bind foo <1>
} -cleanup {
destroy .t.c
} -result {button 1
more button 1}
test bind-7.4 {Tk_CreateBinding procedure: append to non-existing} -body {
canvas .t.c
.t.c bind foo <1> "+button 1"
.t.c bind foo <1>
} -cleanup {
destroy .t.c
} -result {button 1}
test bind-8.1 {Tk_CreateBinding: error} -body {
bind . <xyz> "xyz"
} -returnCodes error -result {bad event type or keysym "xyz"}
test bind-9.1 {Tk_DeleteBinding procedure} -body {
frame .t.f -class Test -width 150 -height 100
bind .t.f <
} -cleanup {
destroy .t.f
} -returnCodes ok
test bind-9.2 {Tk_DeleteBinding procedure} -setup {
set result {}
} -body {
frame .t.f -class Test -width 150 -height 100
foreach i {a b c d} {
bind .t.f $i "binding for $i"
}
foreach i {b d a c} {
bind .t.f $i {}
lappend result [lsort [bind .t.f]]
}
return $result
} -cleanup {
destroy .t.f
} -result {{a c d} {a c} c {}}
test bind-9.3 {Tk_DeleteBinding procedure} -setup {
set result {}
} -body {
frame .t.f -class Test -width 150 -height 100
foreach i {<1> <Meta-1> <Control-1> <Double-Alt-1>} {
bind .t.f $i "binding for $i"
}
foreach i {<Control-1> <Double-Alt-1> <1> <Meta-1>} {
bind .t.f $i {}
lappend result [lsort [bind .t.f]]
}
return $result
} -cleanup {
destroy .t.f
} -result {{<Button-1> <Double-Alt-Button-1> <Meta-Button-1>} {<Button-1> <Meta-Button-1>} <Meta-Button-1> {}}
test bind-10.1 {Tk_GetBinding procedure} -body {
canvas .t.c
.t.c bind foo <
} -cleanup {
destroy .t.c
} -returnCodes error -result {no event type or button # or keysym}
test bind-10.2 {Tk_GetBinding procedure} -body {
canvas .t.c
.t.c bind foo a Test
.t.c bind foo a
} -cleanup {
destroy .t.c
} -result {Test}
test bind-11.1 {Tk_GetAllBindings procedure} -body {
frame .t.f
foreach i "! a \\\{ ~ <Delete> <space> <<Paste>> <Tab> <Linefeed> <less> <Meta-a> <Acircumflex>" {
bind .t.f $i Test
}
lsort [bind .t.f]
} -cleanup {
destroy .t.f
} -result {! <<Paste>> <Key-Acircumflex> <Key-Delete> <Key-Linefeed> <Key-Tab> <Key-less> <Key-space> <Meta-Key-a> a \{ ~}
test bind-11.2 {Tk_GetAllBindings procedure} -body {
frame .t.f
foreach i "<Double-1> <Triple-1> <Meta-Control-a> <Double-Alt-Enter> <1>" {
bind .t.f $i Test
}
lsort [bind .t.f]
} -cleanup {
destroy .t.f
} -result {<Button-1> <Control-Meta-Key-a> <Double-Alt-Enter> <Double-Button-1> <Triple-Button-1>}
test bind-11.3 {Tk_GetAllBindings procedure} -body {
frame .t.f
foreach i "<Double-Triple-1> abcd a<Leave>b" {
bind .t.f $i Test
}
lsort [bind .t.f]
} -cleanup {
destroy .t.f
} -result {<Triple-Button-1> a<Leave>b abcd}
test bind-12.1 {Tk_DeleteAllBindings procedure} -body {
frame .t.f -class Test -width 150 -height 100
destroy .t.f
} -result {}
test bind-12.2 {Tk_DeleteAllBindings procedure} -body {
frame .t.f -class Test -width 150 -height 100
foreach i "a b c <Meta-1> <Alt-a> <Control-a>" {
bind .t.f $i x
}
destroy .t.f
} -result {}
test bind-13.1 {Tk_BindEvent procedure} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind Test <KeyPress> {lappend x "%W %K Test KeyPress"}
bind all <KeyPress> {lappend x "%W %K all KeyPress"}
bind Test : {lappend x "%W %K Test :"}
bind all _ {lappend x "%W %K all _"}
bind .t.f : {lappend x "%W %K .t.f :"}
event generate .t.f <Key-colon>
event generate .t.f <Key-plus>
event generate .t.f <Key-underscore>
return $x
} -cleanup {
destroy .t.f
bind all <KeyPress> {}
bind Test <KeyPress> {}
bind all _ {}
bind Test : {}
} -result {{.t.f colon .t.f :} {.t.f colon Test :} {.t.f colon all KeyPress} {.t.f plus Test KeyPress} {.t.f plus all KeyPress} {.t.f underscore Test KeyPress} {.t.f underscore all _}}
test bind-13.2 {Tk_BindEvent procedure} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind Test <KeyPress> {lappend x "%W %K Test press any"; break}
bind all <KeyPress> {continue; lappend x "%W %K all press any"}
bind .t.f : {lappend x "%W %K .t.f pressed colon"}
event generate .t.f <Key-colon>
return $x
} -cleanup {
destroy .t.f
bind all <KeyPress> {}
bind Test <KeyPress> {}
} -result {{.t.f colon .t.f pressed colon} {.t.f colon Test press any}}
test bind-13.3 {Tk_BindEvent procedure} -setup {
proc bgerror args {}
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind Test <KeyPress> {lappend x "%W %K Test press any"; error Test}
bind .t.f : {lappend x "%W %K .t.f pressed colon"}
event generate .t.f <Key-colon>
update
list $x $errorInfo
} -cleanup {
destroy .t.f
bind Test <KeyPress> {}
rename bgerror {}
} -result {{{.t.f colon .t.f pressed colon} {.t.f colon Test press any}} {Test
while executing
"error Test"
(command bound to event)}}
test bind-13.4 {Tk_BindEvent procedure} -setup {
proc foo {} {
set x 44
event generate .t.f <Key-colon>
}
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind Test : {lappend x "%W %K Test"}
bind .t.f : {lappend x "%W %K .t.f"}
foo
return $x
} -cleanup {
destroy .t.f
bind Test : {}
} -result {{.t.f colon .t.f} {.t.f colon Test}}
test bind-13.5 {Tk_BindEvent procedure} -body {
bind all <Destroy> {lappend x "%W destroyed"}
set x {}
frame .t.g -gorp foo
} -cleanup {
bind all <Destroy> {}
} -returnCodes error -result {unknown option "-gorp"}
test bind-13.6 {Tk_BindEvent procedure} -body {
bind all <Destroy> {lappend x "%W destroyed"}
set x {}
catch {frame .t.g -gorp foo}
return $x
} -cleanup {
bind all <Destroy> {}
} -result {{.t.g destroyed}}
test bind-13.7 {Tk_BindEvent procedure} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f : {lappend x "%W (.t.f binding)"}
bind Test : {lappend x "%W (Test binding)"}
bind all : {bind .t.f : {}; lappend x "%W (all binding)"}
event generate .t.f <Key-colon>
return $x
} -cleanup {
bind Test : {}
bind all : {}
destroy .t.f
} -result {{.t.f (.t.f binding)} {.t.f (Test binding)} {.t.f (all binding)}}
test bind-13.8 {Tk_BindEvent procedure} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f : {lappend x "%W (.t.f binding)"}
bind Test : {lappend x "%W (Test binding)"}
bind all : {destroy .t.f; lappend x "%W (all binding)"}
event generate .t.f <Key-colon>
return $x
} -cleanup {
bind Test : {}
bind all : {}
destroy .t.f
} -result {{.t.f (.t.f binding)} {.t.f (Test binding)} {.t.f (all binding)}}
test bind-13.9 {Tk_BindEvent procedure} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <1> {lappend x "%W z (.t.f <1> binding)"}
bind .t.f <ButtonPress> {lappend x "%W z (.t.f <ButtonPress> binding)"}
event generate .t.f <Button-1>
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
} -result {{.t.f z (.t.f <1> binding)} {.t.f z (.t.f <ButtonPress> binding)}}
test bind-13.10 {Tk_BindEvent procedure: ignore NotifyInferior} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <Enter> "lappend x Enter%#"
bind .t.f <Leave> "lappend x Leave%#"
event generate .t.f <Enter> -serial 100 -detail NotifyAncestor
event generate .t.f <Enter> -serial 101 -detail NotifyInferior
event generate .t.f <Leave> -serial 102 -detail NotifyAncestor
event generate .t.f <Leave> -serial 103 -detail NotifyInferior
return $x
} -cleanup {
destroy .t.f
} -result {Enter100 Leave102}
test bind-13.11 {Tk_BindEvent procedure: collapse Motions} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <Motion> "lappend x Motion%#(%x,%y)"
event generate .t.f <Motion> -serial 100 -x 100 -y 200 -when tail
update
event generate .t.f <Motion> -serial 101 -x 200 -y 300 -when tail
event generate .t.f <Motion> -serial 102 -x 300 -y 400 -when tail
update
return $x
} -cleanup {
destroy .t.f
} -result {Motion100(100,200) Motion102(300,400)}
test bind-13.12 {Tk_BindEvent procedure: collapse repeating modifiers} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
} -body {
bind .t.f <Key> "lappend x %K%#"
bind .t.f <KeyRelease> "lappend x %K%#"
event generate .t.f <Key-Shift_L> -serial 100 -when tail
event generate .t.f <KeyRelease-Shift_L> -serial 101 -when tail
event generate .t.f <Key-Shift_L> -serial 102 -when tail
event generate .t.f <KeyRelease-Shift_L> -serial 103 -when tail
update
} -cleanup {
destroy .t.f
} -result {}
test bind-13.13 {Tk_BindEvent procedure: valid key detail} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <Key> "lappend x Key%K"
bind .t.f <KeyRelease> "lappend x Release%K"
event generate .t.f <Key> -keysym colon
event generate .t.f <KeyRelease> -keysym colon
return $x
} -cleanup {
destroy .t.f
} -result {Keycolon Releasecolon}
test bind-13.14 {Tk_BindEvent procedure: invalid key detail} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <Key> "lappend x Key%K"
bind .t.f <KeyRelease> "lappend x Release%K"
event generate .t.f <Key> -keycode 0
event generate .t.f <KeyRelease> -keycode 0
return $x
} -cleanup {
destroy .t.f
} -result {Key?? Release??}
test bind-13.15 {Tk_BindEvent procedure: button detail} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <Button> "lappend x Button%b"
bind .t.f <ButtonRelease> "lappend x Release%b"
event generate .t.f <Button> -button 1
event generate .t.f <ButtonRelease> -button 3
set x
} -cleanup {
destroy .t.f
} -result {Button1 Release3}
test bind-13.16 {Tk_BindEvent procedure: virtual detail} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <<Paste>> "lappend x Paste"
event generate .t.f <<Paste>>
return $x
} -cleanup {
destroy .t.f
} -result {Paste}
test bind-13.17 {Tk_BindEvent procedure: virtual event in event stream} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <<Paste>> "lappend x Paste"
event generate .t.f <<Paste>>
return $x
} -cleanup {
destroy .t.f
} -result {Paste}
test bind-13.18 {Tk_BindEvent procedure: match detail physical} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <Button-2> {set x Button-2}
event add <<Paste>> <Button-2>
bind .t.f <<Paste>> {set x Paste}
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
event delete <<Paste>> <Button-2>
} -result {Button-2}
test bind-13.19 {Tk_BindEvent procedure: no match detail physical} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
event add <<Paste>> <Button-2>
bind .t.f <<Paste>> {set x Paste}
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
event delete <<Paste>> <Button-2>
} -result {Paste}
test bind-13.20 {Tk_BindEvent procedure: match detail virtual} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
event add <<Paste>> <Button-2>
bind .t.f <<Paste>> "lappend x Paste"
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
event delete <<Paste>> <Button-2>
} -result {Paste}
test bind-13.21 {Tk_BindEvent procedure: no match detail virtual} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
event add <<Paste>> <Button-2>
bind .t.f <<Paste>> "lappend x Paste"
event generate .t.f <Button>
return $x
} -cleanup {
destroy .t.f
event delete <<Paste>> <Button-2>
} -result {}
test bind-13.22 {Tk_BindEvent procedure: match no-detail physical} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <Button> {set x Button}
event add <<Paste>> <Button>
bind .t.f <<Paste>> {set x Paste}
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
event delete <<Paste>> <Button>
} -result {Button}
test bind-13.23 {Tk_BindEvent procedure: no match no-detail physical} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
event add <<Paste>> <Button>
bind .t.f <<Paste>> {set x Paste}
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
event delete <<Paste>> <Button>
} -result {Paste}
test bind-13.24 {Tk_BindEvent procedure: match no-detail virtual} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
event add <<Paste>> <Button>
bind .t.f <<Paste>> "lappend x Paste"
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
event delete <<Paste>> <Button>
} -result {Paste}
test bind-13.25 {Tk_BindEvent procedure: no match no-detail virtual} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
event add <<Paste>> <Key>
bind .t.f <<Paste>> "lappend x Paste"
event generate .t.f <Button>
return $x
} -cleanup {
destroy .t.f
event delete <<Paste>> <Key>
} -result {}
test bind-13.26 {Tk_BindEvent procedure: precedence} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
event add <<Paste>> <Button-2>
event add <<Copy>> <Button>
bind .t.f <Button-2> "lappend x Button-2"
bind .t.f <<Paste>> "lappend x Paste"
bind .t.f <Button> "lappend x Button"
bind .t.f <<Copy>> "lappend x Copy"
event generate .t.f <Button-2>
bind .t.f <Button-2> {}
event generate .t.f <Button-2>
bind .t.f <<Paste>> {}
event generate .t.f <Button-2>
bind .t.f <Button> {}
event generate .t.f <Button-2>
bind .t.f <<Copy>> {}
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
event delete <<Paste>> <Button-2>
event delete <<Copy>> <Button>
} -result {Button-2 Paste Button Copy}
test bind-13.27 {Tk_BindEvent procedure: no detail virtual pattern list} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <Button-2> {set x Button-2}
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
} -result {Button-2}
test bind-13.28 {Tk_BindEvent procedure: detail virtual pattern list} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
event add <<Paste>> <Button-2>
bind .t.f <<Paste>> {set x Paste}
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
event delete <<Paste>> <Button-2>
} -result {Paste}
test bind-13.29 {Tk_BindEvent procedure: no no-detail virtual pattern list} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <Button> {set x Button}
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
} -result {Button}
test bind-13.30 {Tk_BindEvent procedure: no-detail virtual pattern list} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
event add <<Paste>> <Button>
bind .t.f <<Paste>> {set x Paste}
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
event delete <<Paste>> <Button>
} -result {Paste}
test bind-13.31 {Tk_BindEvent procedure: no match} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
} -body {
event generate .t.f <Button-2>
} -cleanup {
destroy .t.f
} -result {}
test bind-13.32 {Tk_BindEvent procedure: match} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <Button-2> {set x Button-2}
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
} -result {Button-2}
test bind-13.33 {Tk_BindEvent procedure: many C bindings cause realloc} -setup {
# this test might not be useful anymore [#3009998]
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bindtags .t.f {a b c d e f g h i j k l m n o p}
foreach p [bindtags .t.f] {
bind $p <1> "lappend x $p"
}
event generate .t.f <1>
return $x
} -cleanup {
foreach p [bindtags .t.f] {bind $p <1> {}}
destroy .t.f
} -result {a b c d e f g h i j k l m n o p}
test bind-13.34 {Tk_BindEvent procedure: multiple tags} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <Button-2> {lappend x .t.f}
bind Test <Button-2> {lappend x Button}
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
bind Test <Button-2> {}
} -result {.t.f Button}
test bind-13.35 {Tk_BindEvent procedure: execute binding} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <1> {lappend x 1}
event generate .t.f <1>
return $x
} -cleanup {
destroy .t.f
} -result {1}
test bind-13.38 {Tk_BindEvent procedure: binding gets to run} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind Test <1> {lappend x Test}
bind .t.f <1> {lappend x .t.f}
event generate .t.f <1>
return $x
} -cleanup {
destroy .t.f
bind Test <1> {}
} -result {.t.f Test}
test bind-13.41 {Tk_BindEvent procedure: continue in script} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
focus -force .t.f
update
set x {}
} -body {
bind .t.f <Button-2> {lappend x b1; continue; lappend x b2}
bind Test <Button-2> {lappend x B1; continue; lappend x B2}
event generate .t.f <Button-2>
return $x
} -cleanup {
destroy .t.f
bind Test <Button-2> {}
} -result {b1 B1}
test bind-13.43 {Tk_BindEvent procedure: break in script} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f