Skip to Main Content
Learning Perl/Tk
book

Learning Perl/Tk

by Nancy Walsh
January 1999
Beginner content levelBeginner
373 pages
9h 43m
English
O'Reilly Media, Inc.
Content preview from Learning Perl/Tk

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();
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl/Tk

Mastering Perl/Tk

Stephen Lidie, Nancy Walsh

Publisher Resources

ISBN: 1565923146Supplemental ContentCatalog PageErrata