use Curses::UI;
my $cui = new Curses::UI;
my $win = $cui->add('window_id', 'Window');
my $checkbox = $win->add(
'mycheckbox', 'Checkbox',
-label => 'Say hello to the world',
-checked => 1,
);
$checkbox->focus();
my $checked = $checkbox->get();
DESCRIPTION
Curses::UI::Checkbox is a widget that can be used to create
a checkbox. A checkbox has a label which says what the
checkbox is about and in front of the label there is a
box which can have an ``X'' in it. If the ``X'' is there, the
checkbox is checked (get will return a true value). If
the box is empty, the checkbox is not checked (get will
return a false value). A checkbox looks like this:
[X] Say hello to the world
See exampes/demo-Curses::UI::Checkbox in the distribution
for a short demo.
For an explanation of these standard options, see
Curses::UI::Widget.
WIDGET-SPECIFIC OPTIONS
* -label < TEXT >
This will set the text label for the checkbox widget
to TEXT.
* -checked < BOOLEAN >
This option determines if at creation time the checkbox
should be checked or not. By default this option is
set to false, so the checkbox is not checked.
* -onchange < CODEREF >
This sets the onChange event handler for the checkbox widget.
If the checkbox is toggled, the code in CODEREF will be executed.
It will get the widget reference as its argument.
METHODS
* new ( OPTIONS )
* layout ( )
* draw ( BOOLEAN )
* intellidraw ( )
* focus ( )
* onFocus ( CODEREF )
* onBlur ( CODEREF )
These are standard methods. See Curses::UI::Widget
for an explanation of these.
* get ( )
This method will return the current state of the checkbox
(0 = not checked, 1 = checked).
* check ( )
This method can be used to set the checkbox to its checked state.
* uncheck ( )
This method can be used to set the checkbox to its unchecked state.
* toggle ( )
This method will set the checkbox in ``the other state''. This means
that the checkbox will get checked if it is not and vice versa.
* onChange ( CODEREF )
This method can be used to set the -onchange event handler
(see above) after initialization of the checkbox.
DEFAULT BINDINGS
* <tab>, <enter>
Call the 'loose-focus' routine. This will have the widget
loose its focus.
* <space>
Call the 'toggle' routine (see the toggle method).
* <0>, <n>
Call the 'uncheck' routine (see the uncheck method).
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.