rtk.CheckBox
¶
A dual- or tri-state checkbox with optional label. Checkboxes are specially styled
buttons, so any attribute from rtk.Button
applies here as well.
local cb = rtk.CheckBox{'Synchronize cardinal grammeters'}
container:add(cb)
cb.onchange = function(self)
app.config.synchronize = self.value
end
type | checkboxtypeconst | read/write |
The type of checkbox, whether dual or tri state (default |
label | string or nil | read/write |
Optional text label for the checkbox (default nil) |
value | checkboxstateconst | read/write |
The current (or desired if setting) value of the checkbox |
toggle() | Toggle to the next state of the checkbox |
The type of checkbox, whether dual or tri state (default DUALSTATE
).
Optional text label for the checkbox (default nil).
This attribute may be passed as the first positional argument during initialization.
(In other words, rtk.CheckBox{'Foo'}
is equivalent to rtk.CheckBox{label='Foo'}
.)
The current (or desired if setting) value of the checkbox.
The strings 'checked'
, 'unchecked'
, and 'indeterminate'
also work here and
when set with attr()
they will be calculated as one of the
state constants.
The checkbox state constants use booleans for UNCHECKED
and
CHECKED
, so truthy evaluations work as you'd intuitively expect:
local cb = rtk.CheckBox()
-- This is safe.
if cb.value then
log.info('checkbox is checked')
end
-- This is equivalent, and actually recommended from a readability standpoint.
if cb.value == rtk.CheckBox.CHECKED then
log.info('yep, still checked')
end
Toggle to the next state of the checkbox.
For a DUALSTATE
checkbox, this simply toggles between CHECKED
and UNCHECKED
.
For TRISTATE
checkboxes, the INDETERMINATE
state will follow CHECKED
and then
cycle back to UNCHECKED
.
The value
attribute is updated after this function is called.
(rtk.CheckBox) | returns self for method chaining |
See also handlers for rtk.Widget.