When a window does a grab, it holds all 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;
$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;