1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

HotkeyBox - Focus fixes

This commit is contained in:
Robert 2023-06-06 20:17:30 +02:00
parent aa4a740b78
commit 34824dde42

View File

@ -79,7 +79,19 @@ public partial class HotkeyBox : UserControl
private void InputServiceOnKeyboardKeyUp(object? sender, ArtemisKeyboardKeyEventArgs e) private void InputServiceOnKeyboardKeyUp(object? sender, ArtemisKeyboardKeyEventArgs e)
{ {
if (e.Modifiers == KeyboardModifierKey.None) if (e.Modifiers == KeyboardModifierKey.None)
Dispatcher.UIThread.Post(() => this.FindAncestorOfType<InputElement>()?.Focus()); Dispatcher.UIThread.Post(ClearFocus);
}
private void ClearFocus()
{
InputElement? element = this.FindAncestorOfType<InputElement>();
if (element == null)
return;
bool wasFocusable = element.Focusable;
element.Focusable = true;
element.Focus();
element.Focusable = wasFocusable;
} }
private void UpdateDisplayTextBox() private void UpdateDisplayTextBox()
@ -97,7 +109,7 @@ public partial class HotkeyBox : UserControl
private void Button_OnClick(object? sender, RoutedEventArgs e) private void Button_OnClick(object? sender, RoutedEventArgs e)
{ {
Hotkey = null; Hotkey = null;
this.FindAncestorOfType<InputElement>()?.Focus(); ClearFocus();
UpdateDisplayTextBox(); UpdateDisplayTextBox();
} }