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


Book HomeMastering Perl/TkSearch this book

9.10. Retrieving Bounding Box Coordinates

When we talked about the scrolling region of a Canvas, we saw an example of the bbox method. The bbox method returns a list with four elements that define the area in which all the specified tags exist. The example used the special "all" tag, which refers to every item in the Canvas. This was how we used it to define our scrolling region. You can specify more than one tag/ID to search for as follows:

($l, $r, $t, $b) = $canvas->bbox("blue", "red");

Assuming that you have been assigning the tags "blue" and "red" to color items appropriately, this code would return the region in the Canvas that encloses all blue and red items.



Library Navigation Links

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