On 06/08/2024 14:31, Helmut Giese wrote:
Well the joy was premature: It works with e.g. buttons but not with
canvas items. And I believre now that it cannot be done:
The 'event generate' command expects a window - in this case the
canvas - and delivers the event there. So I do not see a chance to
deliver different events to individual items on this canvas.
Too bad ...
You have to provide an x- and y coordinate for the canvas to be able to determine which item is affected:
canvas .c -width 500 -height 500
set sq1 [.c create rectangle 100 100 200 200 -fill blue]
set sq2 [.c create rectangle 300 300 400 400 -fill red]
pack .c
.c bind $sq1 <1> {puts "Square 1"}
.c bind $sq2 <1> {puts "Square 2"}
after 1000 {event generate .c <Button-1> -x 120 -y 180}
after 2000 {event generate .c <Button-1> -x 320 -y 380}
The coordinates will have to be adjusted if the canvas is scrolled.
Schelte
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)