mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-12-18 16:43:21 +00:00
17 lines
432 B
Rust
17 lines
432 B
Rust
use dioxus::prelude::*;
|
|
use dioxus_desktop::tao::keyboard::ModifiersState;
|
|
use dioxus_desktop::use_global_shortcut;
|
|
|
|
fn main() {
|
|
dioxus_desktop::launch(app);
|
|
}
|
|
|
|
fn app(cx: Scope) -> Element {
|
|
let toggled = use_state(cx, || false);
|
|
use_global_shortcut(cx, KeyCode::S, ModifiersState::CONTROL, {
|
|
to_owned![toggled];
|
|
move || toggled.modify(|t| !*t)
|
|
});
|
|
|
|
cx.render(rsx!("toggle: {toggled.get()}"))
|
|
}
|