O'Reilly logo

Learning Perl/Tk by Nancy Walsh

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

16.17. Grab Methods

When a window does a "grab" it means that it holds all of the keyboard and mouse input to itself. That window will not allow any other windows in the application to receive input. There is also a global grab, which means that no applications in the entire system can get input except the one window that has done the global grab. These methods are usually called from a toplevel widget.

To do a local grab for the widget, use grab:

$widget->grab();

A local grab means that you can interact with other windows in the system but not with other windows in the application. To do a global grab, use grabGlobal:

$widget->grabGlobal();

To "ungrab", call grabRelease:

$widget->grabRelease();

To find out which widget has done a grab, call grabCurrent:

$who = $widget->grabCurrent();

To find out the current grab state of a $widget, call grabStatus:

$status = $widget->grabStatus();

The grabStatus method returns a string that is "none", "local", or "global".

To find out all the windows that are currently under the influence of grab, use grabs to get a list back:

@windows = $widget->grabs();

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