| Previous | Next
Widget PositionThe methods in this section all deal with the position of a widget. Position Relative to the Root WindowTo determine which widget is at the point (x, y), use the $which = $widget->containing($x, $y); The Coordinates Relative to the ParentYou can get the coordinates of the upper-left corner of a widget by using the $x = $widget->x; $y = $widget->y; Coordinates Relative to the Root WindowTo get the coordinates relative to the root window, use $x = $widget->rootx; $y = $widget->rooty; The coordinates refer to the upper-left corner of the widget. Virtual Desktop CoordinatesIf 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. To determine the height and width of the virtual desktop, use the $height = $widget->vrootheight; $width = $widget->vrootwidth; To get the coordinates of the widget's upper-left corner relative to the virtual desktop, use $x = $widget->vrootx; $y = $widget->vrooty; Each of these four methods returns an empty string if a virtual desktop is not found. Cursor Coordinates Relative to the DesktopYou can use $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). |