mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Clear Focus after 500ms user no input hotkey
This commit is contained in:
parent
1f5478d3c5
commit
c8a9c29463
1 changed files with 12 additions and 5 deletions
|
|
@ -28,7 +28,7 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
private CancellationTokenSource hotkeyUpdateSource;
|
private CancellationTokenSource hotkeyUpdateSource;
|
||||||
|
|
||||||
void TbHotkey_OnPreviewKeyDown(object sender, KeyEventArgs e)
|
private void TbHotkey_OnPreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
hotkeyUpdateSource?.Cancel();
|
hotkeyUpdateSource?.Cancel();
|
||||||
hotkeyUpdateSource?.Dispose();
|
hotkeyUpdateSource?.Dispose();
|
||||||
|
|
@ -56,15 +56,15 @@ namespace Flow.Launcher
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dispatcher.InvokeAsync(async () =>
|
_ = Dispatcher.InvokeAsync(async () =>
|
||||||
{
|
{
|
||||||
await Task.Delay(500);
|
await Task.Delay(500, token);
|
||||||
if (!token.IsCancellationRequested)
|
if (!token.IsCancellationRequested)
|
||||||
SetHotkey(hotkeyModel);
|
await SetHotkey(hotkeyModel);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHotkey(HotkeyModel keyModel, bool triggerValidate = true)
|
public async Task SetHotkey(HotkeyModel keyModel, bool triggerValidate = true)
|
||||||
{
|
{
|
||||||
CurrentHotkey = keyModel;
|
CurrentHotkey = keyModel;
|
||||||
|
|
||||||
|
|
@ -86,6 +86,13 @@ namespace Flow.Launcher
|
||||||
}
|
}
|
||||||
tbMsg.Visibility = Visibility.Visible;
|
tbMsg.Visibility = Visibility.Visible;
|
||||||
OnHotkeyChanged();
|
OnHotkeyChanged();
|
||||||
|
|
||||||
|
var token = hotkeyUpdateSource.Token;
|
||||||
|
await Task.Delay(500, token);
|
||||||
|
if (token.IsCancellationRequested)
|
||||||
|
return;
|
||||||
|
FocusManager.SetFocusedElement(FocusManager.GetFocusScope(this), null);
|
||||||
|
Keyboard.ClearFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue