1
0

shortcut.rs 355 B

1234567891011121314151617
  1. use dioxus::prelude::*;
  2. use dioxus_desktop::use_global_shortcut;
  3. fn main() {
  4. dioxus_desktop::launch(app);
  5. }
  6. fn app(cx: Scope) -> Element {
  7. let toggled = use_state(cx, || false);
  8. use_global_shortcut(cx, "ctrl+s", {
  9. to_owned![toggled];
  10. move || toggled.modify(|t| !*t)
  11. });
  12. cx.render(rsx!("toggle: {toggled.get()}"))
  13. }