9
9
) ) ]
10
10
pub use global_hotkey:: {
11
11
hotkey:: { Code , HotKey } ,
12
- Error as HotkeyError , GlobalHotKeyEvent , GlobalHotKeyManager ,
12
+ Error as HotkeyError , GlobalHotKeyEvent , GlobalHotKeyManager , HotKeyState ,
13
13
} ;
14
14
15
15
#[ cfg( any( target_os = "ios" , target_os = "android" ) ) ]
@@ -53,7 +53,7 @@ pub(crate) struct ShortcutRegistry {
53
53
struct ShortcutInner {
54
54
#[ allow( unused) ]
55
55
shortcut : HotKey ,
56
- callbacks : Slab < Box < dyn FnMut ( ) > > ,
56
+ callbacks : Slab < Box < dyn FnMut ( HotKeyState ) > > ,
57
57
}
58
58
59
59
impl ShortcutRegistry {
@@ -66,21 +66,17 @@ impl ShortcutRegistry {
66
66
67
67
#[ cfg( any( target_os = "windows" , target_os = "linux" , target_os = "macos" ) ) ]
68
68
pub ( crate ) fn call_handlers ( & self , id : GlobalHotKeyEvent ) {
69
- if id. state == global_hotkey:: HotKeyState :: Pressed {
70
- if let Some ( ShortcutInner { callbacks, .. } ) =
71
- self . shortcuts . borrow_mut ( ) . get_mut ( & id. id )
72
- {
73
- for ( _, callback) in callbacks. iter_mut ( ) {
74
- ( callback) ( ) ;
75
- }
69
+ if let Some ( ShortcutInner { callbacks, .. } ) = self . shortcuts . borrow_mut ( ) . get_mut ( & id. id ) {
70
+ for ( _, callback) in callbacks. iter_mut ( ) {
71
+ ( callback) ( id. state ) ;
76
72
}
77
73
}
78
74
}
79
75
80
76
pub ( crate ) fn add_shortcut (
81
77
& self ,
82
78
hotkey : HotKey ,
83
- callback : Box < dyn FnMut ( ) > ,
79
+ callback : Box < dyn FnMut ( HotKeyState ) > ,
84
80
) -> Result < ShortcutHandle , ShortcutRegistryError > {
85
81
let accelerator_id = hotkey. clone ( ) . id ( ) ;
86
82
0 commit comments