Curses::UI::Checkbox(3pm)

Curses::UI::Checkbox3pm

Create and manipulate checkbox widgets

Usage

    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();

Version

Version 1.11

Class hierarchy

 Curses::UI::Widget
    |
    +----Curses::UI::Container
            |
            +----Curses::UI::Checkbox

Overview

Curses::UI::Checkbox provides a checkbox widget.

A checkbox is a control for a boolean value (an on/off toggle). It consists of a box which will either be empty (indicating off or false) or contain an "X" (indicating on or true). Following this is a text label which described the value being controlled.

    [X] This checkbox is on/true/checked/selected
    [ ] This checkbox is off/false/unchecked/deselected

See exampes/demo-Curses::UI::Checkbox in the distribution for a short demo.

Options

    -x  -y   -width    -height
    -pad     -padleft  -padright  -padtop  -padbottom
    -ipad    -ipadleft -ipadright -ipadtop -ipadbottom
    -title   -titlefullwidth      -titlereverse
    -onfocus -onblur
    -parent

See Curses::UI::Widget for an explanation of these.

Options

-label

Sets the initial label for the checkbox widget to the passed string or value.

-checked

Takes a boolean argument. Determines if the widget's initial state is checked or unchecked. The default is false (unchecked).

-onchange

Expects a coderef and sets it as a callback for the widget. When the checkbox's state is changed, the given code will be executed.

Standard methods

    layout draw    intellidraw
    focus  onFocus onBlur

See Curses::UI::Widget for an explanation of these.

Widget-specific methods

get

Returns the current state of the checkbox (0 == unchecked, 1 == checked).

check

Sets the checkbox to "checked".

uncheck

Sets the checkbox to "unchecked".

toggle

Flip-flops the checkbox to its "other" state. If the checkbox is unchecked then it will become checked, and vice versa.

onChange

This method can be used to set the "-onchange" event handler (see above) after initialization of the checkbox. It expects a coderef as its argument.

Default bindings

"[TAB]", "[ENTER}"

Call the 'loose-focus' routine, causing the widget to lose focus.

"[SPACE]"

Call the "toggle" method.

0, "n"

Call the "uncheck" method.

1, "y"

Call the "check" method.

Releases

12 releases since Debian 3.1 (Sarge); the text changed 6 times.

  1. 3.1
  2. 4.0
  3. 5.0
  4. 6.0
  5. 7–10
  6. 11–13
  7. Arch

Author

Shawn Boyette "<[email protected]>"

From perl-curses-ui 0.9609-15 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.