Curses::UI::Buttonbox - Create and manipulate button widgets
Curses::UI::Widget | +----Curses::UI::Buttonbox
use Curses::UI; my $cui = new Curses::UI; my $win = $cui->add('window_id', 'Window');
my $buttons = $win->add( 'mybuttons', 'Buttonbox', -buttons => [ { -label => '< Button 1 >', -value => 1, -shortcut => 1 },{ -label => '< Button 2 >', -value => 2, -shortcut => 2 } ] );
$buttons->focus(); my $value = $buttons->get();
For an explanation of these standard options, see Curses::UI::Widget.
* Your own button definition
A button definition is a reference to a hash. This hash can have the following key-value pairs:
obligatory: -----------
-label This determines what text should be drawn on the button.
optional: ---------
-value This determines the returnvalue for the get() method. If the value is not defined, the get() method will return the index of the button.
-shortcut The button will act as if it was pressed if the key defined by -shortcut is pressed
-onpress If the value for -onpress is a CODE reference, this code will be executes if the button is pressed, before the buttons widget loses focus and returns.
* Predefined button type
This module has a predefined list of frequently used button types. Using these in B<-buttons> makes things a lot easier. The predefined button types are:
ok -label => '< OK >' -shortcut => 'o' -value => 1 -onpress => undef
cancel -label => '< Cancel >' -shortcut => 'c' -value => 0 -onpress => undef
yes -label => '< Yes >' -shortcut => 'y' -value => 1 -onpress => undef
no -label => '< No >' -shortcut => 'n' -value => 0 -onpress => undef
Example:
.... -buttons => [ { -label => '< My own button >', -value => 'mine!', -shortcut => 'm' },
'ok',
'cancel',
{ -label => '< My second button >', -value => 'another one', -shortcut => 's', -onpress => sub { die "Do not press this button!\n" } } ] ....
$buttonswidget->set_routine('loose-focus', 'RETURN');
For an explanation of set_routine, see Curses::UI::Widget.
Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de)
This package is free software and is provided ``as is'' without express or implied warranty. It may be used, redistributed and/or modified under the same terms as perl itself.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |