Tk::autobind - automatically bind a widget to an ALT-key
use Tk::autobind;
$widget->autobind(callback);
Tk::autobind offers a convenient way to set up a form and have ALT-key bindings for the widgets on that form. All you have to do is call autobind after you create a widget. If the widget has an -underline configuration option set to a value greater than or equal to 0, its ALT-key binding is the key at that location in the widget's -text configuration option.
Tk::autobind
autobind
-underline
-text
For example, if you have a Checkbutton with the following -text:
Automatically fix
and its -underline value is set to 0, then if the user presses ALT-A while the focus is in the widget's main window, the checkbutton widget will be invoked.
The binding that is generated is essentially
$widget->toplevel->bind('<Alt-Key-x>', $callback);
Adds the binding given above. If callback is specified, it must be one of the forms of a valid Tk callback (see Tk::callbacks). If it is omitted, a closure is generated and used:
sub { $widget->Invoke }
If callback is explicitly set to an empty string, the binding is removed.
This method always returns $widget to allow method chaining. For example, you can stick autobind before the call to pack:
my $checkbutton = $mw->Checkbutton(Name => 'cb1')->autobind->pack;
Tk::bind
Kevin Michael Vail <kevin@vaildc.net>
To install Tk::autobind, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tk::autobind
CPAN shell
perl -MCPAN -e shell install Tk::autobind
For more information on module installation, please visit the detailed CPAN module installation guide.