1 |
578 |
markom |
# This file is a Tcl script to test out the "focus" command and the
|
2 |
|
|
# other procedures in the file tkFocus.c. It is organized in the
|
3 |
|
|
# standard fashion for Tcl tests.
|
4 |
|
|
#
|
5 |
|
|
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
|
6 |
|
|
#
|
7 |
|
|
# See the file "license.terms" for information on usage and redistribution
|
8 |
|
|
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
9 |
|
|
#
|
10 |
|
|
# RCS: @(#) $Id: focus.test,v 1.1.1.1 2002-01-16 10:25:58 markom Exp $
|
11 |
|
|
|
12 |
|
|
if {$tcl_platform(platform) != "unix"} {
|
13 |
|
|
return
|
14 |
|
|
}
|
15 |
|
|
|
16 |
|
|
if {[info procs test] != "test"} {
|
17 |
|
|
source defs
|
18 |
|
|
}
|
19 |
|
|
|
20 |
|
|
eval destroy [winfo children .]
|
21 |
|
|
wm geometry . {}
|
22 |
|
|
raise .
|
23 |
|
|
|
24 |
|
|
button .b -text .b -relief raised -bd 2
|
25 |
|
|
pack .b
|
26 |
|
|
|
27 |
|
|
proc focusSetup {} {
|
28 |
|
|
catch {destroy .t}
|
29 |
|
|
toplevel .t
|
30 |
|
|
wm geom .t +0+0
|
31 |
|
|
foreach i {b1 b2 b3 b4} {
|
32 |
|
|
button .t.$i -text .t.$i -relief raised -bd 2
|
33 |
|
|
pack .t.$i
|
34 |
|
|
}
|
35 |
|
|
tkwait visibility .t.b4
|
36 |
|
|
}
|
37 |
|
|
proc focusSetupAlt {} {
|
38 |
|
|
global env
|
39 |
|
|
catch {destroy .alt}
|
40 |
|
|
toplevel .alt -screen $env(TK_ALT_DISPLAY)
|
41 |
|
|
wm withdraw .alt
|
42 |
|
|
foreach i {a b c d} {
|
43 |
|
|
button .alt.$i -text .alt.$i -relief raised -bd 2
|
44 |
|
|
pack .alt.$i
|
45 |
|
|
}
|
46 |
|
|
tkwait visibility .alt.d
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
# Make sure the window manager knows who has focus
|
50 |
|
|
fixfocus
|
51 |
|
|
|
52 |
|
|
# The following procedure ensures that there is no input focus
|
53 |
|
|
# in this application. It does it by arranging for another
|
54 |
|
|
# application to grab the focus. The "after" and "update" stuff
|
55 |
|
|
# is needed to wait long enough for pending actions to get through
|
56 |
|
|
# the X server and possibly also the window manager.
|
57 |
|
|
|
58 |
|
|
setupbg
|
59 |
|
|
proc focusClear {} {
|
60 |
|
|
global x;
|
61 |
|
|
after 200 {set x 1}
|
62 |
|
|
tkwait variable x
|
63 |
|
|
dobg {focus -force .; update}
|
64 |
|
|
update
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
focusSetup
|
68 |
|
|
set altDisplay [info exists env(TK_ALT_DISPLAY)]
|
69 |
|
|
if $altDisplay {
|
70 |
|
|
focusSetupAlt
|
71 |
|
|
}
|
72 |
|
|
update
|
73 |
|
|
|
74 |
|
|
bind all {
|
75 |
|
|
append focusInfo "in %W %d\n"
|
76 |
|
|
}
|
77 |
|
|
bind all {
|
78 |
|
|
append focusInfo "out %W %d\n"
|
79 |
|
|
}
|
80 |
|
|
bind all {
|
81 |
|
|
append focusInfo "press %W %K"
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
test focus-1.1 {Tk_FocusCmd procedure} {
|
85 |
|
|
focusClear
|
86 |
|
|
focus
|
87 |
|
|
} {}
|
88 |
|
|
if $altDisplay {
|
89 |
|
|
test focus-1.2 {Tk_FocusCmd procedure} {
|
90 |
|
|
focus .alt.b
|
91 |
|
|
focus
|
92 |
|
|
} {}
|
93 |
|
|
}
|
94 |
|
|
test focus-1.3 {Tk_FocusCmd procedure} {
|
95 |
|
|
focusClear
|
96 |
|
|
focus .t.b3
|
97 |
|
|
focus
|
98 |
|
|
} {}
|
99 |
|
|
test focus-1.4 {Tk_FocusCmd procedure} {
|
100 |
|
|
list [catch {focus ""} msg] $msg
|
101 |
|
|
} {0 {}}
|
102 |
|
|
test focus-1.5 {Tk_FocusCmd procedure} {
|
103 |
|
|
focusClear
|
104 |
|
|
focus -force .t
|
105 |
|
|
focus .t.b3
|
106 |
|
|
focus
|
107 |
|
|
} {.t.b3}
|
108 |
|
|
test focus-1.6 {Tk_FocusCmd procedure} {
|
109 |
|
|
list [catch {focus .gorp} msg] $msg
|
110 |
|
|
} {1 {bad window path name ".gorp"}}
|
111 |
|
|
test focus-1.7 {Tk_FocusCmd procedure} {
|
112 |
|
|
list [catch {focus .gorp a} msg] $msg
|
113 |
|
|
} {1 {bad option ".gorp": must be -displayof, -force, or -lastfor}}
|
114 |
|
|
test focus-1.8 {Tk_FocusCmd procedure, focussing on dead window} {
|
115 |
|
|
toplevel .t2
|
116 |
|
|
wm geom .t2 +10+10
|
117 |
|
|
frame .t2.f -width 200 -height 100 -bd 2 -relief raised
|
118 |
|
|
frame .t2.f2 -width 200 -height 100 -bd 2 -relief raised
|
119 |
|
|
pack .t2.f .t2.f2
|
120 |
|
|
bind .t2.f {focus .t2.f}
|
121 |
|
|
bind .t2.f2 {focus .t2}
|
122 |
|
|
focus -force .t2.f2
|
123 |
|
|
tkwait visibility .t2.f2
|
124 |
|
|
update
|
125 |
|
|
set x [focus]
|
126 |
|
|
destroy .t2.f2
|
127 |
|
|
lappend x [focus]
|
128 |
|
|
destroy .t2.f
|
129 |
|
|
lappend x [focus]
|
130 |
|
|
destroy .t2
|
131 |
|
|
set x
|
132 |
|
|
} {.t2.f2 .t2 .t2}
|
133 |
|
|
test focus-1.9 {Tk_FocusCmd procedure, -displayof option} {
|
134 |
|
|
list [catch {focus -displayof} msg] $msg
|
135 |
|
|
} {1 {wrong # args: should be "focus -displayof window"}}
|
136 |
|
|
test focus-1.10 {Tk_FocusCmd procedure, -displayof option} {
|
137 |
|
|
list [catch {focus -displayof a b} msg] $msg
|
138 |
|
|
} {1 {wrong # args: should be "focus -displayof window"}}
|
139 |
|
|
test focus-1.11 {Tk_FocusCmd procedure, -displayof option} {
|
140 |
|
|
list [catch {focus -displayof .lousy} msg] $msg
|
141 |
|
|
} {1 {bad window path name ".lousy"}}
|
142 |
|
|
test focus-1.12 {Tk_FocusCmd procedure, -displayof option} {
|
143 |
|
|
focusClear
|
144 |
|
|
focus .t
|
145 |
|
|
focus -displayof .t.b3
|
146 |
|
|
} {}
|
147 |
|
|
test focus-1.13 {Tk_FocusCmd procedure, -displayof option} {
|
148 |
|
|
focusClear
|
149 |
|
|
focus -force .t
|
150 |
|
|
focus -displayof .t.b3
|
151 |
|
|
} {.t}
|
152 |
|
|
if $altDisplay {
|
153 |
|
|
test focus-1.14 {Tk_FocusCmd procedure, -displayof option} {
|
154 |
|
|
focus -force .alt.c
|
155 |
|
|
focus -displayof .alt
|
156 |
|
|
} {.alt.c}
|
157 |
|
|
}
|
158 |
|
|
test focus-1.15 {Tk_FocusCmd procedure, -force option} {
|
159 |
|
|
list [catch {focus -force} msg] $msg
|
160 |
|
|
} {1 {wrong # args: should be "focus -force window"}}
|
161 |
|
|
test focus-1.16 {Tk_FocusCmd procedure, -force option} {
|
162 |
|
|
list [catch {focus -force a b} msg] $msg
|
163 |
|
|
} {1 {wrong # args: should be "focus -force window"}}
|
164 |
|
|
test focus-1.17 {Tk_FocusCmd procedure, -force option} {
|
165 |
|
|
list [catch {focus -force foo} msg] $msg
|
166 |
|
|
} {1 {bad window path name "foo"}}
|
167 |
|
|
test focus-1.18 {Tk_FocusCmd procedure, -force option} {
|
168 |
|
|
list [catch {focus -force ""} msg] $msg
|
169 |
|
|
} {0 {}}
|
170 |
|
|
test focus-1.19 {Tk_FocusCmd procedure, -force option} {
|
171 |
|
|
focusClear
|
172 |
|
|
focus .t.b1
|
173 |
|
|
set x [list [focus]]
|
174 |
|
|
focus -force .t.b1
|
175 |
|
|
lappend x [focus]
|
176 |
|
|
} {{} .t.b1}
|
177 |
|
|
test focus-1.20 {Tk_FocusCmd procedure, -lastfor option} {
|
178 |
|
|
list [catch {focus -lastfor} msg] $msg
|
179 |
|
|
} {1 {wrong # args: should be "focus -lastfor window"}}
|
180 |
|
|
test focus-1.21 {Tk_FocusCmd procedure, -lastfor option} {
|
181 |
|
|
list [catch {focus -lastfor 1 2} msg] $msg
|
182 |
|
|
} {1 {wrong # args: should be "focus -lastfor window"}}
|
183 |
|
|
test focus-1.22 {Tk_FocusCmd procedure, -lastfor option} {
|
184 |
|
|
list [catch {focus -lastfor who_knows?} msg] $msg
|
185 |
|
|
} {1 {bad window path name "who_knows?"}}
|
186 |
|
|
test focus-1.23 {Tk_FocusCmd procedure, -lastfor option} {
|
187 |
|
|
focus .b
|
188 |
|
|
focus .t.b1
|
189 |
|
|
list [focus -lastfor .] [focus -lastfor .t.b3]
|
190 |
|
|
} {.b .t.b1}
|
191 |
|
|
test focus-1.24 {Tk_FocusCmd procedure, -lastfor option} {
|
192 |
|
|
destroy .t
|
193 |
|
|
focusSetup
|
194 |
|
|
update
|
195 |
|
|
focus -lastfor .t.b2
|
196 |
|
|
} {.t}
|
197 |
|
|
test focus-1.25 {Tk_FocusCmd procedure} {
|
198 |
|
|
list [catch {focus -unknown} msg] $msg
|
199 |
|
|
} {1 {bad option "-unknown": must be -displayof, -force, or -lastfor}}
|
200 |
|
|
|
201 |
|
|
if {[string compare testwrapper [info commands testwrapper]] != 0} {
|
202 |
|
|
puts "This application hasn't been compiled with the testwrapper command,"
|
203 |
|
|
puts "therefore I am skipping all of these tests."
|
204 |
|
|
return
|
205 |
|
|
}
|
206 |
|
|
|
207 |
|
|
test focus-2.1 {TkFocusFilterEvent procedure} {nonPortable} {
|
208 |
|
|
focus -force .b
|
209 |
|
|
destroy .t
|
210 |
|
|
focusSetup
|
211 |
|
|
update
|
212 |
|
|
set focusInfo {}
|
213 |
|
|
event gen [testwrapper .t] -detail NotifyAncestor -sendevent 0x54217567
|
214 |
|
|
list $focusInfo
|
215 |
|
|
} {{}}
|
216 |
|
|
test focus-2.2 {TkFocusFilterEvent procedure} {nonPortable} {
|
217 |
|
|
focus -force .b
|
218 |
|
|
destroy .t
|
219 |
|
|
focusSetup
|
220 |
|
|
update
|
221 |
|
|
set focusInfo {}
|
222 |
|
|
event gen .t -detail NotifyAncestor -sendevent 0x547321ac
|
223 |
|
|
list $focusInfo [focus]
|
224 |
|
|
} {{in .t NotifyAncestor
|
225 |
|
|
} .b}
|
226 |
|
|
test focus-2.3 {TkFocusFilterEvent procedure} {nonPortable} {
|
227 |
|
|
focus -force .b
|
228 |
|
|
destroy .t
|
229 |
|
|
focusSetup
|
230 |
|
|
update
|
231 |
|
|
set focusInfo {}
|
232 |
|
|
event gen [testwrapper .t] -detail NotifyAncestor
|
233 |
|
|
update
|
234 |
|
|
list $focusInfo [focus -lastfor .t]
|
235 |
|
|
} {{out .b NotifyNonlinear
|
236 |
|
|
out . NotifyNonlinearVirtual
|
237 |
|
|
in .t NotifyNonlinear
|
238 |
|
|
} .t}
|
239 |
|
|
test focus-2.4 {TkFocusFilterEvent procedure, FocusIn events} {nonPortable} {
|
240 |
|
|
set result {}
|
241 |
|
|
focus .t.b1
|
242 |
|
|
# Important to end with NotifyAncestor, which is an
|
243 |
|
|
# event that is processed normally. This has a side
|
244 |
|
|
# effect on text 2.5
|
245 |
|
|
foreach detail {NotifyAncestor NotifyNonlinear
|
246 |
|
|
NotifyNonlinearVirtual NotifyPointer NotifyPointerRoot
|
247 |
|
|
NotifyVirtual NotifyAncestor} {
|
248 |
|
|
focus -force .
|
249 |
|
|
update
|
250 |
|
|
event gen [testwrapper .t] -detail $detail
|
251 |
|
|
set focusInfo {}
|
252 |
|
|
update
|
253 |
|
|
lappend result $focusInfo
|
254 |
|
|
}
|
255 |
|
|
set result
|
256 |
|
|
} {{out . NotifyNonlinear
|
257 |
|
|
in .t NotifyNonlinearVirtual
|
258 |
|
|
in .t.b1 NotifyNonlinear
|
259 |
|
|
} {out . NotifyNonlinear
|
260 |
|
|
in .t NotifyNonlinearVirtual
|
261 |
|
|
in .t.b1 NotifyNonlinear
|
262 |
|
|
} {} {out . NotifyNonlinear
|
263 |
|
|
in .t NotifyNonlinearVirtual
|
264 |
|
|
in .t.b1 NotifyNonlinear
|
265 |
|
|
} {} {} {out . NotifyNonlinear
|
266 |
|
|
in .t NotifyNonlinearVirtual
|
267 |
|
|
in .t.b1 NotifyNonlinear
|
268 |
|
|
}}
|
269 |
|
|
test focus-2.5 {TkFocusFilterEvent procedure, creating FocusInfo struct} {nonPortable} {
|
270 |
|
|
focusSetup
|
271 |
|
|
focus .t.b1
|
272 |
|
|
update
|
273 |
|
|
event gen [testwrapper .t] -detail NotifyAncestor
|
274 |
|
|
list $focusInfo [focus]
|
275 |
|
|
} {{out . NotifyNonlinear
|
276 |
|
|
in .t NotifyNonlinearVirtual
|
277 |
|
|
in .t.b1 NotifyNonlinear
|
278 |
|
|
} .t.b1}
|
279 |
|
|
test focus-2.6 {TkFocusFilterEvent procedure, FocusIn events} {
|
280 |
|
|
focus .t.b1
|
281 |
|
|
focus .
|
282 |
|
|
update
|
283 |
|
|
event gen [testwrapper .t] -detail NotifyAncestor
|
284 |
|
|
set focusInfo {}
|
285 |
|
|
set x [focus]
|
286 |
|
|
event gen .
|
287 |
|
|
list $x $focusInfo
|
288 |
|
|
} {.t.b1 {press .t.b1 x}}
|
289 |
|
|
test focus-2.7 {TkFocusFilterEvent procedure, FocusOut events} {
|
290 |
|
|
set result {}
|
291 |
|
|
foreach detail {NotifyAncestor NotifyInferior NotifyNonlinear
|
292 |
|
|
NotifyNonlinearVirtual NotifyPointer NotifyPointerRoot
|
293 |
|
|
NotifyVirtual} {
|
294 |
|
|
focus -force .t.b1
|
295 |
|
|
event gen [testwrapper .t] -detail $detail
|
296 |
|
|
update
|
297 |
|
|
lappend result [focus]
|
298 |
|
|
}
|
299 |
|
|
set result
|
300 |
|
|
} {{} .t.b1 {} {} .t.b1 .t.b1 {}}
|
301 |
|
|
test focus-2.8 {TkFocusFilterEvent procedure, FocusOut events} {
|
302 |
|
|
focus -force .t.b1
|
303 |
|
|
event gen .t.b1 -detail NotifyAncestor
|
304 |
|
|
focus
|
305 |
|
|
} {.t.b1}
|
306 |
|
|
test focus-2.9 {TkFocusFilterEvent procedure, FocusOut events} {
|
307 |
|
|
focus .t.b1
|
308 |
|
|
event gen [testwrapper .] -detail NotifyAncestor
|
309 |
|
|
focus
|
310 |
|
|
} {}
|
311 |
|
|
test focus-2.10 {TkFocusFilterEvent procedure, Enter events} {
|
312 |
|
|
set result {}
|
313 |
|
|
focus .t.b1
|
314 |
|
|
focusClear
|
315 |
|
|
foreach detail {NotifyAncestor NotifyInferior NotifyNonlinear
|
316 |
|
|
NotifyNonlinearVirtual NotifyVirtual} {
|
317 |
|
|
event gen [testwrapper .t] -detail $detail -focus 1
|
318 |
|
|
update
|
319 |
|
|
lappend result [focus]
|
320 |
|
|
event gen [testwrapper .t] -detail NotifyAncestor
|
321 |
|
|
update
|
322 |
|
|
}
|
323 |
|
|
set result
|
324 |
|
|
} {.t.b1 {} .t.b1 .t.b1 .t.b1}
|
325 |
|
|
test focus-2.11 {TkFocusFilterEvent procedure, Enter events} {
|
326 |
|
|
focusClear
|
327 |
|
|
set focusInfo {}
|
328 |
|
|
event gen [testwrapper .t] -detail NotifyAncestor
|
329 |
|
|
update
|
330 |
|
|
set focusInfo
|
331 |
|
|
} {}
|
332 |
|
|
test focus-2.12 {TkFocusFilterEvent procedure, Enter events} {
|
333 |
|
|
focus -force .b
|
334 |
|
|
update
|
335 |
|
|
set focusInfo {}
|
336 |
|
|
event gen [testwrapper .t] -detail NotifyAncestor -focus 1
|
337 |
|
|
update
|
338 |
|
|
set focusInfo
|
339 |
|
|
} {}
|
340 |
|
|
test focus-2.13 {TkFocusFilterEvent procedure, Enter events} {
|
341 |
|
|
focus .t.b1
|
342 |
|
|
focusClear
|
343 |
|
|
event gen [testwrapper .t] -detail NotifyAncestor -focus 1
|
344 |
|
|
set focusInfo {}
|
345 |
|
|
update
|
346 |
|
|
set focusInfo
|
347 |
|
|
} {in .t NotifyVirtual
|
348 |
|
|
in .t.b1 NotifyAncestor
|
349 |
|
|
}
|
350 |
|
|
test focus-2.14 {TkFocusFilterEvent procedure, Enter events, ignore errors when setting focus due to implicit focus} {
|
351 |
|
|
focusClear
|
352 |
|
|
catch {destroy .t2}
|
353 |
|
|
toplevel .t2
|
354 |
|
|
wm withdraw .t2
|
355 |
|
|
update
|
356 |
|
|
set focusInfo {}
|
357 |
|
|
event gen [testwrapper .t2] -detail NotifyAncestor -focus 1
|
358 |
|
|
update
|
359 |
|
|
destroy .t2
|
360 |
|
|
} {}
|
361 |
|
|
test focus-2.15 {TkFocusFilterEvent procedure, Leave events} {
|
362 |
|
|
set result {}
|
363 |
|
|
focus .t.b1
|
364 |
|
|
foreach detail {NotifyAncestor NotifyInferior NotifyNonlinear
|
365 |
|
|
NotifyNonlinearVirtual NotifyVirtual} {
|
366 |
|
|
focusClear
|
367 |
|
|
event gen [testwrapper .t] -detail NotifyAncestor -focus 1
|
368 |
|
|
update
|
369 |
|
|
event gen [testwrapper .t] -detail $detail
|
370 |
|
|
update
|
371 |
|
|
lappend result [focus]
|
372 |
|
|
}
|
373 |
|
|
set result
|
374 |
|
|
} {{} .t.b1 {} {} {}}
|
375 |
|
|
test focus-2.16 {TkFocusFilterEvent procedure, Leave events} {
|
376 |
|
|
set result {}
|
377 |
|
|
focus .t.b1
|
378 |
|
|
event gen [testwrapper .t] -detail NotifyAncestor -focus 1
|
379 |
|
|
update
|
380 |
|
|
set focusInfo {}
|
381 |
|
|
event gen [testwrapper .t] -detail NotifyAncestor
|
382 |
|
|
update
|
383 |
|
|
set focusInfo
|
384 |
|
|
} {out .t.b1 NotifyAncestor
|
385 |
|
|
out .t NotifyVirtual
|
386 |
|
|
}
|
387 |
|
|
test focus-2.17 {TkFocusFilterEvent procedure, Leave events} {
|
388 |
|
|
set result {}
|
389 |
|
|
focus .t.b1
|
390 |
|
|
event gen [testwrapper .t] -detail NotifyAncestor -focus 1
|
391 |
|
|
update
|
392 |
|
|
set focusInfo {}
|
393 |
|
|
event gen .t.b1 -detail NotifyAncestor
|
394 |
|
|
event gen [testwrapper .] -detail NotifyAncestor
|
395 |
|
|
update
|
396 |
|
|
list $focusInfo [focus]
|
397 |
|
|
} {{out .t.b1 NotifyAncestor
|
398 |
|
|
out .t NotifyVirtual
|
399 |
|
|
} {}}
|
400 |
|
|
|
401 |
|
|
test focus-3.1 {SetFocus procedure, create record on focus} {
|
402 |
|
|
toplevel .t2 -width 250 -height 100
|
403 |
|
|
wm geometry .t2 +0+0
|
404 |
|
|
update
|
405 |
|
|
focus -force .t2
|
406 |
|
|
update
|
407 |
|
|
focus
|
408 |
|
|
} {.t2}
|
409 |
|
|
catch {destroy .t2}
|
410 |
|
|
# This test produces no result, but it will generate a protocol
|
411 |
|
|
# error if Tk forgets to make the window exist before focussing
|
412 |
|
|
# on it.
|
413 |
|
|
test focus-3.2 {SetFocus procedure, making window exist} {
|
414 |
|
|
update
|
415 |
|
|
button .b2 -text "Another button"
|
416 |
|
|
focus .b2
|
417 |
|
|
update
|
418 |
|
|
} {}
|
419 |
|
|
catch {destroy .b2}
|
420 |
|
|
update
|
421 |
|
|
# The following test doesn't produce a check-able result, but if
|
422 |
|
|
# there are bugs it may generate an X protocol error.
|
423 |
|
|
test focus-3.3 {SetFocus procedure, delaying claim of X focus} {
|
424 |
|
|
focusSetup
|
425 |
|
|
focus -force .t.b2
|
426 |
|
|
update
|
427 |
|
|
} {}
|
428 |
|
|
test focus-3.4 {SetFocus procedure, delaying claim of X focus} {
|
429 |
|
|
focusSetup
|
430 |
|
|
wm withdraw .t
|
431 |
|
|
focus -force .t.b2
|
432 |
|
|
toplevel .t2 -width 250 -height 100
|
433 |
|
|
wm geometry .t2 +10+10
|
434 |
|
|
focus -force .t2
|
435 |
|
|
wm withdraw .t2
|
436 |
|
|
update
|
437 |
|
|
wm deiconify .t2
|
438 |
|
|
wm deiconify .t
|
439 |
|
|
} {}
|
440 |
|
|
catch {destroy .t2}
|
441 |
|
|
test focus-3.5 {SetFocus procedure, generating events} {
|
442 |
|
|
focusSetup
|
443 |
|
|
focusClear
|
444 |
|
|
set focusInfo {}
|
445 |
|
|
focus -force .t.b2
|
446 |
|
|
update
|
447 |
|
|
set focusInfo
|
448 |
|
|
} {in .t NotifyVirtual
|
449 |
|
|
in .t.b2 NotifyAncestor
|
450 |
|
|
}
|
451 |
|
|
test focus-3.6 {SetFocus procedure, generating events} {
|
452 |
|
|
focusSetup
|
453 |
|
|
focus -force .b
|
454 |
|
|
update
|
455 |
|
|
set focusInfo {}
|
456 |
|
|
focus .t.b2
|
457 |
|
|
update
|
458 |
|
|
set focusInfo
|
459 |
|
|
} {out .b NotifyNonlinear
|
460 |
|
|
out . NotifyNonlinearVirtual
|
461 |
|
|
in .t NotifyNonlinearVirtual
|
462 |
|
|
in .t.b2 NotifyNonlinear
|
463 |
|
|
}
|
464 |
|
|
test focus-3.7 {SetFocus procedure, generating events} {nonPortable} {
|
465 |
|
|
# Non-portable because some platforms generate extra events.
|
466 |
|
|
|
467 |
|
|
focusSetup
|
468 |
|
|
focusClear
|
469 |
|
|
set focusInfo {}
|
470 |
|
|
focus .t.b2
|
471 |
|
|
update
|
472 |
|
|
set focusInfo
|
473 |
|
|
} {}
|
474 |
|
|
|
475 |
|
|
test focus-4.1 {TkFocusDeadWindow procedure} {
|
476 |
|
|
focusSetup
|
477 |
|
|
update
|
478 |
|
|
focus -force .b
|
479 |
|
|
update
|
480 |
|
|
destroy .t
|
481 |
|
|
focus
|
482 |
|
|
} {.b}
|
483 |
|
|
test focus-4.2 {TkFocusDeadWindow procedure} {
|
484 |
|
|
focusSetup
|
485 |
|
|
update
|
486 |
|
|
focus -force .t.b2
|
487 |
|
|
focus .b
|
488 |
|
|
update
|
489 |
|
|
destroy .t.b2
|
490 |
|
|
update
|
491 |
|
|
focus
|
492 |
|
|
} {.b}
|
493 |
|
|
|
494 |
|
|
# Non-portable due to wm-specific redirection of input focus when
|
495 |
|
|
# windows are deleted:
|
496 |
|
|
|
497 |
|
|
test focus-4.3 {TkFocusDeadWindow procedure} {nonPortable} {
|
498 |
|
|
focusSetup
|
499 |
|
|
update
|
500 |
|
|
focus .t
|
501 |
|
|
update
|
502 |
|
|
destroy .t
|
503 |
|
|
update
|
504 |
|
|
focus
|
505 |
|
|
} {}
|
506 |
|
|
test focus-4.4 {TkFocusDeadWindow procedure} {
|
507 |
|
|
focusSetup
|
508 |
|
|
focus -force .t.b2
|
509 |
|
|
update
|
510 |
|
|
destroy .t.b2
|
511 |
|
|
focus
|
512 |
|
|
} {.t}
|
513 |
|
|
|
514 |
|
|
# I don't know how to test most of the remaining procedures of this file
|
515 |
|
|
# explicitly; they've already been exercised by the preceding tests.
|
516 |
|
|
|
517 |
|
|
test focus-5.1 {ChangeXFocus procedure, don't take focus unless have it} {
|
518 |
|
|
focusSetup
|
519 |
|
|
focus -force .t
|
520 |
|
|
update
|
521 |
|
|
set result [focus]
|
522 |
|
|
send [dobg {tk appname}] {focus -force .; update}
|
523 |
|
|
lappend result [focus]
|
524 |
|
|
focus .t.b2
|
525 |
|
|
update
|
526 |
|
|
lappend result [focus]
|
527 |
|
|
} {.t .t {}}
|
528 |
|
|
|
529 |
|
|
catch {destroy .t}
|
530 |
|
|
bind all {}
|
531 |
|
|
bind all {}
|
532 |
|
|
bind all {}
|
533 |
|
|
cleanupbg
|
534 |
|
|
fixfocus
|
535 |
|
|
|
536 |
|
|
test focus-6.1 {miscellaneous - embedded application in same process} {unixOnly} {
|
537 |
|
|
eval interp delete [interp slaves]
|
538 |
|
|
catch {destroy .t}
|
539 |
|
|
toplevel .t
|
540 |
|
|
wm geometry .t +0+0
|
541 |
|
|
frame .t.f1 -container 1
|
542 |
|
|
frame .t.f2
|
543 |
|
|
pack .t.f1 .t.f2
|
544 |
|
|
entry .t.f2.e1 -bg red
|
545 |
|
|
pack .t.f2.e1
|
546 |
|
|
bind all {lappend x "focus in %W %d"}
|
547 |
|
|
bind all {lappend x "focus out %W %d"}
|
548 |
|
|
interp create child
|
549 |
|
|
child eval "set argv {-use [winfo id .t.f1]}"
|
550 |
|
|
load {} tk child
|
551 |
|
|
child eval {
|
552 |
|
|
entry .e1 -bg lightBlue
|
553 |
|
|
pack .e1
|
554 |
|
|
bind all {lappend x "focus in %W %d"}
|
555 |
|
|
bind all {lappend x "focus out %W %d"}
|
556 |
|
|
set x {}
|
557 |
|
|
}
|
558 |
|
|
|
559 |
|
|
# Claim the focus and wait long enough for it to really arrive.
|
560 |
|
|
|
561 |
|
|
focus -force .t.f2.e1
|
562 |
|
|
after 300 {set timer 1}
|
563 |
|
|
vwait timer
|
564 |
|
|
set x {}
|
565 |
|
|
lappend x [focus] [child eval focus]
|
566 |
|
|
|
567 |
|
|
# See if a "focus" command will move the focus to the embedded
|
568 |
|
|
# application.
|
569 |
|
|
|
570 |
|
|
child eval {focus .e1}
|
571 |
|
|
after 300 {set timer 1}
|
572 |
|
|
vwait timer
|
573 |
|
|
lappend x |
|
574 |
|
|
child eval {lappend x |}
|
575 |
|
|
|
576 |
|
|
# Bring the focus back to the main application.
|
577 |
|
|
|
578 |
|
|
focus .t.f2.e1
|
579 |
|
|
after 300 {set timer 1}
|
580 |
|
|
vwait timer
|
581 |
|
|
set result [list $x [child eval {set x}]]
|
582 |
|
|
interp delete child
|
583 |
|
|
set result
|
584 |
|
|
} {{.t.f2.e1 {} {focus out .t.f2.e1 NotifyNonlinear} {focus out .t.f2 NotifyNonlinearVirtual} {focus in .t.f1 NotifyNonlinear} | {focus out .t.f1 NotifyNonlinear} {focus in .t.f2 NotifyNonlinearVirtual} {focus in .t.f2.e1 NotifyNonlinear}} {{focus in . NotifyVirtual} {focus in .e1 NotifyAncestor} | {focus out .e1 NotifyAncestor} {focus out . NotifyVirtual}}}
|
585 |
|
|
test focus-6.2 {miscellaneous - embedded application in different process} {unixOnly} {
|
586 |
|
|
eval interp delete [interp slaves]
|
587 |
|
|
catch {destroy .t}
|
588 |
|
|
setupbg
|
589 |
|
|
toplevel .t
|
590 |
|
|
wm geometry .t +0+0
|
591 |
|
|
frame .t.f1 -container 1
|
592 |
|
|
frame .t.f2
|
593 |
|
|
pack .t.f1 .t.f2
|
594 |
|
|
entry .t.f2.e1 -bg red
|
595 |
|
|
pack .t.f2.e1
|
596 |
|
|
bind all {lappend x "focus in %W %d"}
|
597 |
|
|
bind all {lappend x "focus out %W %d"}
|
598 |
|
|
setupbg -use [winfo id .t.f1]
|
599 |
|
|
dobg {
|
600 |
|
|
entry .e1 -bg lightBlue
|
601 |
|
|
pack .e1
|
602 |
|
|
bind all {lappend x "focus in %W %d"}
|
603 |
|
|
bind all {lappend x "focus out %W %d"}
|
604 |
|
|
set x {}
|
605 |
|
|
}
|
606 |
|
|
|
607 |
|
|
# Claim the focus and wait long enough for it to really arrive.
|
608 |
|
|
|
609 |
|
|
focus -force .t.f2.e1
|
610 |
|
|
after 300 {set timer 1}
|
611 |
|
|
vwait timer
|
612 |
|
|
set x {}
|
613 |
|
|
lappend x [focus] [dobg focus]
|
614 |
|
|
|
615 |
|
|
# See if a "focus" command will move the focus to the embedded
|
616 |
|
|
# application.
|
617 |
|
|
|
618 |
|
|
dobg {focus .e1}
|
619 |
|
|
after 300 {set timer 1}
|
620 |
|
|
vwait timer
|
621 |
|
|
lappend x |
|
622 |
|
|
dobg {lappend x |}
|
623 |
|
|
|
624 |
|
|
# Bring the focus back to the main application.
|
625 |
|
|
|
626 |
|
|
focus .t.f2.e1
|
627 |
|
|
after 300 {set timer 1}
|
628 |
|
|
vwait timer
|
629 |
|
|
set result [list $x [dobg {set x}]]
|
630 |
|
|
cleanupbg
|
631 |
|
|
set result
|
632 |
|
|
} {{.t.f2.e1 {} {focus out .t.f2.e1 NotifyNonlinear} {focus out .t.f2 NotifyNonlinearVirtual} {focus in .t.f1 NotifyNonlinear} | {focus out .t.f1 NotifyNonlinear} {focus in .t.f2 NotifyNonlinearVirtual} {focus in .t.f2.e1 NotifyNonlinear}} {{focus in . NotifyVirtual} {focus in .e1 NotifyAncestor} | {focus out .e1 NotifyAncestor} {focus out . NotifyVirtual}}}
|
633 |
|
|
|
634 |
|
|
eval destroy [winfo children .]
|
635 |
|
|
bind all {}
|
636 |
|
|
bind all {}
|