Provide HotkeyState on Global Shortcut Events (#3822)

* Only react to hotkeys that are pressed

The global shortcuts are otherwise also triggering when the hotkey is
being released. This affects at least Windows.

* Provide `HotkeyState` on Global Shortcut Events

Instead of ignoring the events where the shortcut is released, the state
is now provided as an argument to the event handler.
This commit is contained in:
Christopher Serr authored and GitHub committed 2025-04-09 11:04:06 -07:00
1 parent e0ecf0eb49
commit 3da821d184
7 files changed
+34 -15

No files matched your search

+10
View File
@@ -78,6 +78,16 @@ impl fmt::Display for HotkeyError {
pub struct GlobalHotKeyEvent {
pub id: u32,
pub state: HotKeyState,
}
/// Describes the state of the hotkey.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum HotKeyState {
/// The hotkey is pressed.
Pressed,
/// The hotkey is released.
Released,
}
pub(crate) type Code = dioxus_html::input_data::keyboard_types::Code;