home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeMastering Perl/TkSearch this book

9.11. Translating Coordinates

When you set up a callback and use the Ev('x') and/or Ev('y') arguments to find out where the user clicked, you must translate that information into Canvas coordinates (Ev is explained in Chapter 15, "Anatomy of the MainLoop"). To do this, use the canvasx and canvasy methods:

$x = $canvas->canvasx(screenx [, gridspacing ]);
$y = $canvas->canvasy(screeny [, gridspacing ]);

Each method takes an optional gridspacing argument; the Canvas coordinate value will be rounded to the nearest value to fit the grid.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.