Skip to content

Commit

Permalink
Fix not being able to use certain valid key combinations for hotkeys (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz authored Apr 10, 2024
1 parent e4f61e5 commit 716785f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 0 additions & 1 deletion LightBulb/Views/Controls/HotKeyTextBox.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
x:Name="TextBox"
IsReadOnly="True"
IsUndoEnabled="False"
KeyDown="TextBox_OnKeyDown"
Text="{Binding $parent[UserControl].HotKey, Mode=OneWay}"
TextAlignment="Center" />
</UserControl>
9 changes: 8 additions & 1 deletion LightBulb/Views/Controls/HotKeyTextBox.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Interactivity;
using LightBulb.Models;

namespace LightBulb.Views.Controls;
Expand All @@ -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
{
Expand Down

0 comments on commit 716785f

Please sign in to comment.