bug in tkinter canvas event handling?

Doug Hellmann doughellmann at home.com
Tue Nov 30 13:12:53 CET 1999


"Garrett G. Hodgson" wrote:
> 
> ok, i'm back with another tk problem.
> what i want to do is attach a callback to a shape in a canvas
> that will tell me which domain level object was picked.
> 
> seems simple, but i don't get what i expect.  in particular,
> if i press a mouse button while pointing to one object, then drag
> to another and release, the release event callback tells me i
> was pointing to the first object.  i've distilled it down to a
> small test case, attached below.
> 
> this seems like a bug to me, but experience has shown that it's
> probably a misconception on my part about how the event handling
> is supposed to work.

This behavior surprised me at first, too.  It's as though the first
canvas object is grabbing the pointer so that all events go to it.  I
got around the problem by looking for the x,y coords of the release
event and then finding the object(s) under that point on the canvas.

Doug




More information about the Python-list mailing list