#1129 Error processing events (bug&workaround)

obsolete: 8.3.4
open
Jeffrey Hobbs
5
2002-01-31
2002-01-31
No

Please watch the code below, run it
an call nogo. Behavior:
Tcl-Error for generated event. The idea behind the
code is to generate an event when an item in the
canvas is picked ny the user.
The function doeswork does the same with a frame
and widgets, here processing generated events
works fine.
The code has been distilled from a much more
complex example.

proc f {} {
catch {event generate $::evw <Button-1> -x 15 -y 15
-when mark}
}
proc cb1 {} {puts cb1}
proc cb2 {} {puts cb2; f}

proc nogo {} {
toplevel .t
set ::evw [canvas .t.c];
pack .t.c -fill both -expand 1
set ::r1 [.t.c create rect 10 10 20 20 -fill red]
set ::r2 [.t.c create rect 100 10 110 20 -fill
green]
$::evw bind $::r1 <ButtonPress-1> "cb1";
$::evw bind $::r2 <ButtonPress-1> "cb2";
}

proc doeswork {} {
toplevel .t
set ::r1 [frame .t.f1 -bg green -width 10 -height
10];
place .t.f1 -x 10 -y 10
set ::r2 [frame .t.f2 -bg red -width 10 -height
10];
place .t.f2 -x 100 -y 10
set ::evw $::r1;
bind $::r1 <ButtonPress-1> cb1;
bind $::r2 <ButtonPress-1> cb2;
}

Possible WORKAROUND:
in generic/tkEvent.cTk_HandleEvent, lines 559..578:
deactive these lines with #if 0/#endif will make
this example and many other cases work, but it
breaks some of the tests coming with Tk.
I have currently no idea about the consequences
of this workaround, but I used it for 8.3.2/8.3.3
as well. I assume the correct fix needs to touch
the canvas widget C-code dealing with event handling.

Discussion