Sujet : Curious event behaviour De : hgiese (at) *nospam* ratiosoft.com (Helmut Giese) Groupes :comp.lang.tcl Date : 31. Aug 2024, 14:49:33 Autres entêtes Organisation : ratiosoft Message-ID :<v176dj9u5vmca0l5cc320f2ph8dd8tnmne@4ax.com> User-Agent : Forte Free Agent 1.93/32.576 English (American)
Hello out there, take the following script: --- package require Tk foreach ch [winfo children "."] {destroy $ch}
# This variable controls whether the events happen during the script's # execution or are scheduled for some time after set evInScript 0
set c [canvas .c -width 400 -height 300 -bd 0 -bg lightyellow] pack $c set id1 [$c create rectangle 100 100 200 200 -fill red] set id2 [$c create rectangle 200 100 300 200 -fill green]
foreach id [list $id1 $id2] { $c bind $id <Button-1> [list puts "<Button-1> for id $id"] $c bind $id <Shift-Button-1> [list puts "<Shift-Button-1> for id $id"] } if {$evInScript} { after 1000 event generate $c <Button-1> -x 150 -y 150 after 2000 event generate $c <Shift-Button-1> -x 250 -y 150 } else { after 1000 {event generate $c <Button-1> -x 150 -y 150} after 2000 {event generate $c <Shift-Button-1> -x 250 -y 150} } puts "Done for evInScript == $evInScript" --- It programs two events which are to be executed either "inline" in the script (evInScript == 1) or scheduled for some time after. This is the result: --- Microsoft Windows [Version 10.0.19045.4842] (c) Microsoft Corporation. Alle Rechte vorbehalten.
d:\proj\_ToolsSE\Skeleton\TclTests>tclsh tst.tcl Done for evInScript == 0 <Button-1> for id 1 <Shift-Button-1> for id 2
d:\proj\_ToolsSE\Skeleton\TclTests>tclsh tst.tcl Done for evInScript == 1 --- In the second case the events never happened (or they happened but were not recognized, which amounts to the same). I consider this a bug. Should I submit a ticket?
This is on Windows 10 with Tcl 8.6.10 and 8.6.13 Helmut