checkbox Widget
A checkbox widget to displays the value of a boolean (true or false) variable. The user can tap the widget to toggle the value of the variable.
Attributes:
var_name: "var1
- Variable name
- Required
actions: [action]
- A list of actions to perform when the user taps the button
- When the list is empty, the button is disabled.
initial_bool: true
- The initial value of the variable, if the variable is unset.
poll_delay_ms: 0
- Poll (update) the page immediately when the user changes the checkbox state.
- Use this for search boxes.
poll_delay_ms: N
- Poll (update) the page after the user changes the checkbox state and N milliseconds passes.
- Use this to validate selections and show warnings.
text: "Label1
- A label to display next to the checkbox.
Example
# Ruby
nav_page(title: "Checkbox") {
scroll {
form(widgets: [
checkbox(text: "Option 1", var_name: "option_1"),
checkbox(text: "Option 2", var_name: "option_2", initial_bool: true),
checkbox(text: "Option 3", var_name: "option_3", rpc: "/ok"),
checkbox(text: "", var_name: "no_label"),
checkbox(
text: "MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM",
var_name: "many_words",
),
checkbox(
text: "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM",
var_name: "long_word",
),
checkbox(text: "Polls page", var_name: "poll", actions: [Applin::poll]),
checkbox(
text: "Polls page after 1 second delay",
var_name: "poll_delay",
poll_delay_ms: 1000,
),
])
}
}
#![allow(unused)] fn main() { // Rust nav_page( "Checkbox", scroll(form(( checkbox("option_1").with_text("Option 1"), checkbox("option_2").with_text("Option 2").with_initial_bool(true), checkbox("option_3").with_text("Option 3").with_rpc("/ok"), checkbox("no_label"), checkbox("many_words") .with_text("MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM MMMM"), checkbox("long_word") .with_text("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"), checkbox("polls") .with_text("Polls page") .with_poll_delay(Duration::ZERO), checkbox("poll_delay") .with_text("Polls page after 1 second delay") .with_poll_delay(Duration::from_secs(1)), ))), ) }