From 083dc2ffb4c3203a9e3479f22f241ef3fb396116 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Wed, 10 Apr 2024 03:08:32 +0300 Subject: [PATCH] Fix not being able to use certain valid key combinations for hotkeys Closes #284 --- LightBulb/Views/Controls/HotKeyTextBox.axaml | 1 - LightBulb/Views/Controls/HotKeyTextBox.axaml.cs | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/LightBulb/Views/Controls/HotKeyTextBox.axaml b/LightBulb/Views/Controls/HotKeyTextBox.axaml index 18a465f..15737ed 100644 --- a/LightBulb/Views/Controls/HotKeyTextBox.axaml +++ b/LightBulb/Views/Controls/HotKeyTextBox.axaml @@ -6,7 +6,6 @@ x:Name="TextBox" IsReadOnly="True" IsUndoEnabled="False" - KeyDown="TextBox_OnKeyDown" Text="{Binding $parent[UserControl].HotKey, Mode=OneWay}" TextAlignment="Center" /> diff --git a/LightBulb/Views/Controls/HotKeyTextBox.axaml.cs b/LightBulb/Views/Controls/HotKeyTextBox.axaml.cs index 77ac137..60712be 100644 --- a/LightBulb/Views/Controls/HotKeyTextBox.axaml.cs +++ b/LightBulb/Views/Controls/HotKeyTextBox.axaml.cs @@ -2,6 +2,7 @@ using Avalonia.Controls; using Avalonia.Data; using Avalonia.Input; +using Avalonia.Interactivity; using LightBulb.Models; namespace LightBulb.Views.Controls; @@ -13,7 +14,13 @@ public partial class HotKeyTextBox : UserControl HotKey >(nameof(HotKey), defaultBindingMode: BindingMode.TwoWay); - public HotKeyTextBox() => InitializeComponent(); + public HotKeyTextBox() + { + InitializeComponent(); + + // Bind the event with the tunnel strategy to handle keys that take part in writing text + TextBox.AddHandler(KeyDownEvent, TextBox_OnKeyDown, RoutingStrategies.Tunnel); + } public HotKey HotKey {