8
8
using Flow . Launcher . Helper ;
9
9
using Flow . Launcher . Infrastructure . Hotkey ;
10
10
using Flow . Launcher . Plugin ;
11
+ using System . Threading ;
11
12
12
13
namespace Flow . Launcher
13
14
{
@@ -25,8 +26,14 @@ public HotkeyControl()
25
26
InitializeComponent ( ) ;
26
27
}
27
28
29
+ private CancellationTokenSource hotkeyUpdateSource ;
30
+
28
31
void TbHotkey_OnPreviewKeyDown ( object sender , KeyEventArgs e )
29
32
{
33
+ hotkeyUpdateSource ? . Cancel ( ) ;
34
+ hotkeyUpdateSource ? . Dispose ( ) ;
35
+ hotkeyUpdateSource = new ( ) ;
36
+ var token = hotkeyUpdateSource . Token ;
30
37
e . Handled = true ;
31
38
tbMsg . Visibility = Visibility . Hidden ;
32
39
@@ -52,7 +59,8 @@ void TbHotkey_OnPreviewKeyDown(object sender, KeyEventArgs e)
52
59
Dispatcher . InvokeAsync ( async ( ) =>
53
60
{
54
61
await Task . Delay ( 500 ) ;
55
- SetHotkey ( hotkeyModel ) ;
62
+ if ( ! token . IsCancellationRequested )
63
+ SetHotkey ( hotkeyModel ) ;
56
64
} ) ;
57
65
}
58
66
@@ -78,7 +86,6 @@ public void SetHotkey(HotkeyModel keyModel, bool triggerValidate = true)
78
86
}
79
87
tbMsg . Visibility = Visibility . Visible ;
80
88
OnHotkeyChanged ( ) ;
81
- Keyboard . ClearFocus ( ) ;
82
89
}
83
90
}
84
91
@@ -89,9 +96,6 @@ public void SetHotkey(string keyStr, bool triggerValidate = true)
89
96
90
97
private bool CheckHotkeyAvailability ( ) => HotKeyMapper . CheckAvailability ( CurrentHotkey ) ;
91
98
92
- public new bool IsFocused
93
- {
94
- get { return tbHotkey . IsFocused ; }
95
- }
99
+ public new bool IsFocused => tbHotkey . IsFocused ;
96
100
}
97
- }
101
+ }
0 commit comments