📄 focus.test
字号:
event gen [testwrapper .t] <Leave> -detail NotifyAncestor update } set result} {.t.b1 {} .t.b1 .t.b1 .t.b1}test focus-2.11 {TkFocusFilterEvent procedure, Enter events} { focusClear set focusInfo {} event gen [testwrapper .t] <Enter> -detail NotifyAncestor update set focusInfo} {}test focus-2.12 {TkFocusFilterEvent procedure, Enter events} { focus -force .b update set focusInfo {} event gen [testwrapper .t] <Enter> -detail NotifyAncestor -focus 1 update set focusInfo} {}test focus-2.13 {TkFocusFilterEvent procedure, Enter events} { focus .t.b1 focusClear event gen [testwrapper .t] <Enter> -detail NotifyAncestor -focus 1 set focusInfo {} update set focusInfo} {in .t NotifyVirtualin .t.b1 NotifyAncestor}test focus-2.14 {TkFocusFilterEvent procedure, Enter events, ignore errors when setting focus due to implicit focus} { focusClear catch {destroy .t2} toplevel .t2 wm withdraw .t2 update set focusInfo {} event gen [testwrapper .t2] <Enter> -detail NotifyAncestor -focus 1 update destroy .t2} {}test focus-2.15 {TkFocusFilterEvent procedure, Leave events} { set result {} focus .t.b1 foreach detail {NotifyAncestor NotifyInferior NotifyNonlinear NotifyNonlinearVirtual NotifyVirtual} { focusClear event gen [testwrapper .t] <Enter> -detail NotifyAncestor -focus 1 update event gen [testwrapper .t] <Leave> -detail $detail update lappend result [focus] } set result} {{} .t.b1 {} {} {}}test focus-2.16 {TkFocusFilterEvent procedure, Leave events} { set result {} focus .t.b1 event gen [testwrapper .t] <Enter> -detail NotifyAncestor -focus 1 update set focusInfo {} event gen [testwrapper .t] <Leave> -detail NotifyAncestor update set focusInfo} {out .t.b1 NotifyAncestorout .t NotifyVirtual}test focus-2.17 {TkFocusFilterEvent procedure, Leave events} { set result {} focus .t.b1 event gen [testwrapper .t] <Enter> -detail NotifyAncestor -focus 1 update set focusInfo {} event gen .t.b1 <Leave> -detail NotifyAncestor event gen [testwrapper .] <Leave> -detail NotifyAncestor update list $focusInfo [focus]} {{out .t.b1 NotifyAncestorout .t NotifyVirtual} {}}test focus-3.1 {SetFocus procedure, create record on focus} { toplevel .t2 -width 250 -height 100 wm geometry .t2 +0+0 update focus -force .t2 update focus} {.t2}catch {destroy .t2}# This test produces no result, but it will generate a protocol# error if Tk forgets to make the window exist before focussing# on it.test focus-3.2 {SetFocus procedure, making window exist} { update button .b2 -text "Another button" focus .b2 update} {}catch {destroy .b2}update# The following test doesn't produce a check-able result, but if# there are bugs it may generate an X protocol error.test focus-3.3 {SetFocus procedure, delaying claim of X focus} { focusSetup focus -force .t.b2 update} {}test focus-3.4 {SetFocus procedure, delaying claim of X focus} { focusSetup wm withdraw .t focus -force .t.b2 toplevel .t2 -width 250 -height 100 wm geometry .t2 +10+10 focus -force .t2 wm withdraw .t2 update wm deiconify .t2 wm deiconify .t} {}catch {destroy .t2}test focus-3.5 {SetFocus procedure, generating events} { focusSetup focusClear set focusInfo {} focus -force .t.b2 update set focusInfo} {in .t NotifyVirtualin .t.b2 NotifyAncestor}test focus-3.6 {SetFocus procedure, generating events} { focusSetup focus -force .b update set focusInfo {} focus .t.b2 update set focusInfo} {out .b NotifyNonlinearout . NotifyNonlinearVirtualin .t NotifyNonlinearVirtualin .t.b2 NotifyNonlinear}test focus-3.7 {SetFocus procedure, generating events} {nonPortable} { # Non-portable because some platforms generate extra events. focusSetup focusClear set focusInfo {} focus .t.b2 update set focusInfo} {}test focus-4.1 {TkFocusDeadWindow procedure} { focusSetup update focus -force .b update destroy .t focus} {.b}test focus-4.2 {TkFocusDeadWindow procedure} { focusSetup update focus -force .t.b2 focus .b update destroy .t.b2 update focus} {.b}# Non-portable due to wm-specific redirection of input focus when# windows are deleted:test focus-4.3 {TkFocusDeadWindow procedure} {nonPortable} { focusSetup update focus .t update destroy .t update focus} {}test focus-4.4 {TkFocusDeadWindow procedure} { focusSetup focus -force .t.b2 update destroy .t.b2 focus} {.t}# I don't know how to test most of the remaining procedures of this file# explicitly; they've already been exercised by the preceding tests.test focus-5.1 {ChangeXFocus procedure, don't take focus unless have it} { focusSetup focus -force .t update set result [focus] send [dobg {tk appname}] {focus -force .; update} lappend result [focus] focus .t.b2 update lappend result [focus]} {.t .t {}}catch {destroy .t}bind all <FocusIn> {}bind all <FocusOut> {}bind all <KeyPress> {}cleanupbgfixfocustest focus-6.1 {miscellaneous - embedded application in same process} {unixOnly} { eval interp delete [interp slaves] catch {destroy .t} toplevel .t wm geometry .t +0+0 frame .t.f1 -container 1 frame .t.f2 pack .t.f1 .t.f2 entry .t.f2.e1 -bg red pack .t.f2.e1 bind all <FocusIn> {lappend x "focus in %W %d"} bind all <FocusOut> {lappend x "focus out %W %d"} interp create child child eval "set argv {-use [winfo id .t.f1]}" load {} tk child child eval { entry .e1 -bg lightBlue pack .e1 bind all <FocusIn> {lappend x "focus in %W %d"} bind all <FocusOut> {lappend x "focus out %W %d"} set x {} } # Claim the focus and wait long enough for it to really arrive. focus -force .t.f2.e1 after 300 {set timer 1} vwait timer set x {} lappend x [focus] [child eval focus] # See if a "focus" command will move the focus to the embedded # application. child eval {focus .e1} after 300 {set timer 1} vwait timer lappend x | child eval {lappend x |} # Bring the focus back to the main application. focus .t.f2.e1 after 300 {set timer 1} vwait timer set result [list $x [child eval {set x}]] interp delete child set result} {{.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}}}test focus-6.2 {miscellaneous - embedded application in different process} {unixOnly} { eval interp delete [interp slaves] catch {destroy .t} setupbg toplevel .t wm geometry .t +0+0 frame .t.f1 -container 1 frame .t.f2 pack .t.f1 .t.f2 entry .t.f2.e1 -bg red pack .t.f2.e1 bind all <FocusIn> {lappend x "focus in %W %d"} bind all <FocusOut> {lappend x "focus out %W %d"} setupbg -use [winfo id .t.f1] dobg { entry .e1 -bg lightBlue pack .e1 bind all <FocusIn> {lappend x "focus in %W %d"} bind all <FocusOut> {lappend x "focus out %W %d"} set x {} } # Claim the focus and wait long enough for it to really arrive. focus -force .t.f2.e1 after 300 {set timer 1} vwait timer set x {} lappend x [focus] [dobg focus] # See if a "focus" command will move the focus to the embedded # application. dobg {focus .e1} after 300 {set timer 1} vwait timer lappend x | dobg {lappend x |} # Bring the focus back to the main application. focus .t.f2.e1 after 300 {set timer 1} vwait timer set result [list $x [dobg {set x}]] cleanupbg set result} {{.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}}}eval destroy [winfo children .]bind all <FocusIn> {}bind all <FocusOut> {}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -