Canvas - Rectangle. Is there an easy way to detect if you're inside?

Marc mnations at airmail.net
Thu Sep 11 15:59:38 EDT 2003


Hi all,

I've been using the canvas quite a bit lately, and I am wondering if I
am just missing a quick trick somewhere.

With most canvas objects you can bind then to mouse functions and
quickly determine if you are selecting them. However, the rectangle
(and I'm sure all other objects that aren't solid) only register if
you actually hit the frame of the object, if it's transparent. If you
fill it with color then it will register anywhere.

At the moment I am doing as series of if-then statements involving
coordinates and the positions that the rectangles hold to determine if
the mouse is somewhere inside the rectangle. However it would be much
simpler if there was a way to quickly recognize the internal area of a
rectangle using a canvas function.

Is there an easier way to do this? I've looked at all the canvas
functions and none really make this process easier unless the
rectangle can auto-recognize itself.

Many Thanks,
Marc




More information about the Python-list mailing list