13.10. Widget Position
13.10.1. Position Relative to the Root Window
$which = $widget->containing($x, $y);
The $x and $y coordinates must be relative to the root window (or on a Microsoft Windows system, the desktop). An empty string is returned if there is no widget found at those coordinates. If there are several widgets located at those coordinates, the one closest to the front is returned.
13.10.2. Coordinates Relative to the Parent
$x = $widget->x; $y = $widget->y;
13.10.3. Coordinates Relative to the Root Window
$x = $widget->rootx; $y = $widget->rooty;
The coordinates refer to the upper-left corner of the widget.
13.10.4. Virtual Desktop Coordinates
If you have a virtual desktop, there are special methods that give coordinates relative to the virtual desktop. Virtual desktops are very common on the X Window System (such as the fvwm and tvtwm window managers), but they exist on Microsoft Windows as well.
$height = $widget->vrootheight; $width = $widget->vrootwidth;
$x = $widget->vrootx; $y = $widget->vrooty;
Each of these four methods returns an empty string if a virtual desktop is not found.
13.10.5. Cursor Coordinates Relative to the Desktop
$x = $widget->pointerx; $y = $widget->pointery; ($x, $y) = $widget->pointerxy;
All the coordinates returned are relative to the desktop (even if it is a virtual desktop).
Copyright © 2002 O'Reilly & Associates. All rights reserved.