checkbox (cellium v0.1.0)
View SourceCheckbox widget module for togglable boolean options.
This module provides an interactive checkbox widget that displays a label with a checkable box. When focused, colors are inverted.
Usage
Basic checkbox:
checkbox:new(my_checkbox, "Enable feature")Checkbox with initial checked state:
Widget = checkbox:new(my_checkbox, "Enable feature"),
CheckedWidget = Widget#{checked => true}Properties
label(string): Text label displayed next to the checkboxchecked(boolean): Whether the checkbox is checked. Default: falsefocusable(boolean): Set to true by default
Display
- Unchecked:
[ ] Label - Checked:
[X] Label - When focused, foreground and background colors are swapped
Event Handling
Toggle the checkbox state in your update function when handling space or enter key events on this widget.
Summary
Functions
Handles keyboard events for the checkbox. Toggles checked state on Space or Enter.
Creates a new checkbox with default label 'Checkbox'.
Creates a new checkbox with the specified label.
Renders the checkbox in unfocused state.
Renders the checkbox in focused state with inverted colors.
Functions
Handles keyboard events for the checkbox. Toggles checked state on Space or Enter.
Creates a new checkbox with default label 'Checkbox'.
Creates a new checkbox with the specified label.
Renders the checkbox in unfocused state.
Renders the checkbox in focused state with inverted colors.