O'Reilly logo

Practical Programming in Tcl & Tk, Third Edition by Brent B. Welch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hints

Screen Coordinates vs. Canvas Coordinates

The canvasx and canvasy operations map from a screen coordinate to a canvas coordinate. If the scroll region is larger than the display area, then you need to use these operations to map from the X and Y in an event (i.e., %x and %y) and the canvas coordinates. The typical use is:

set id [$c find closest [$c canvasx %x] [$c canvasy %y]]

Large Coordinate Spaces

Coordinates for canvas items are stored internally as floating point numbers, so the values returned by the coords operation will be floating point numbers. If you have a very large canvas, you may need to adjust the precision with which you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required