cushy/examples/checkbox.rs
Jonathan Johnson 1c8d4e0176
ButtonClick + Overlays at locations
The overlay example now supports right-clicking to open overlays at the
clicked location, showing how a context menu widget can begin being
built.
2024-05-08 08:38:26 -07:00

20 lines
611 B
Rust

use cushy::value::{Destination, Dynamic, Source};
use cushy::widget::MakeWidget;
use cushy::widgets::checkbox::{Checkable, CheckboxState};
use cushy::Run;
fn main() -> cushy::Result {
let checkbox_state = Dynamic::new(CheckboxState::Checked);
let label = checkbox_state.map_each(|state| format!("Check Me! Current: {state:?}"));
checkbox_state
.clone()
.to_checkbox(label)
.and("Maybe".into_button().on_click(move |_| {
checkbox_state.set(CheckboxState::Indeterminant);
}))
.into_columns()
.centered()
.expand()
.run()
}