From 1f0ec791cfe397b6ddbbcb7fa1dc4ca2f4ab8ef0 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Mon, 10 Apr 2023 10:36:24 +0100 Subject: [PATCH] Ui - Fixed every hotkey in the same tree receiving input --- src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs b/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs index 9bfbe96b4..dfa5bd38c 100644 --- a/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs @@ -36,16 +36,20 @@ public class HotkeyBox : UserControl UpdateDisplayTextBox(); } - protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) + protected override void OnGotFocus(GotFocusEventArgs e) { _inputService.KeyboardKeyDown += InputServiceOnKeyboardKeyDown; _inputService.KeyboardKeyUp += InputServiceOnKeyboardKeyUp; + + base.OnGotFocus(e); } - protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) + protected override void OnLostFocus(RoutedEventArgs e) { _inputService.KeyboardKeyDown -= InputServiceOnKeyboardKeyDown; _inputService.KeyboardKeyUp -= InputServiceOnKeyboardKeyUp; + + base.OnLostFocus(e); } private static void HotkeyChanging(IAvaloniaObject sender, bool before)