Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix not being able to use certain valid key combinations for hotkeys #285

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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