From 51aef34c6248aaaad0c44f31f0d81f0f77892ea9 Mon Sep 17 00:00:00 2001 From: Sergey Nechaev <6499856+snechaev@users.noreply.github.com> Date: Tue, 23 Sep 2025 20:56:50 +0200 Subject: [PATCH 1/2] Add InputGesture atttibute to MenuItems in order to display hotkeys in the UI. The HotKey attribute must still be set for hotkeys to be handled automatically. --- .../MainWindow.xaml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/StructuredLogViewer.Avalonia/MainWindow.xaml b/src/StructuredLogViewer.Avalonia/MainWindow.xaml index 73c7c475c..a5bd9cd8a 100644 --- a/src/StructuredLogViewer.Avalonia/MainWindow.xaml +++ b/src/StructuredLogViewer.Avalonia/MainWindow.xaml @@ -15,20 +15,26 @@ + HotKey="F6" + InputGesture="F6"/> + HotKey="Shift+F6" + InputGesture="Shift+F6"/> + HotKey="Ctrl+O" + InputGesture="Ctrl+O"/> + HotKey="F5" + InputGesture="F5"/> + HotKey="Ctrl+S" + InputGesture="Ctrl+S" + /> + HotKey="Alt+F4" + InputGesture="Alt+F4"/> Date: Tue, 23 Sep 2025 20:57:47 +0200 Subject: [PATCH 2/2] Do not handle the menuitems-assigned hotkeys manually. This fix should prevent the menu-attached actions from being called twice. Fixes #904. --- .../MainWindow.xaml.cs | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/StructuredLogViewer.Avalonia/MainWindow.xaml.cs b/src/StructuredLogViewer.Avalonia/MainWindow.xaml.cs index 397f55777..aa9c55dbd 100644 --- a/src/StructuredLogViewer.Avalonia/MainWindow.xaml.cs +++ b/src/StructuredLogViewer.Avalonia/MainWindow.xaml.cs @@ -518,23 +518,7 @@ await System.Threading.Tasks.Task.Run(() => private async void Window_KeyUp(object sender, KeyEventArgs e) { - if (e.Key == Key.F5) - { - Reload(); - } - else if (e.Key == Key.F6 && e.KeyModifiers.HasFlag(KeyModifiers.Shift)) - { - RebuildProjectOrSolution(); - } - else if (e.Key == Key.F6) - { - await OpenProjectOrSolution(); - } - else if (e.Key == Key.O && e.KeyModifiers.HasFlag(KeyModifiers.Control)) - { - await OpenLogFile(); - } - else if (e.Key == Key.F && e.KeyModifiers.HasFlag(KeyModifiers.Control)) + if (e.Key == Key.F && e.KeyModifiers.HasFlag(KeyModifiers.Control)) { FocusSearch(); } @@ -546,10 +530,6 @@ private async void Window_KeyUp(object sender, KeyEventArgs e) await Clipboard.SetTextAsync(content.MSBuildCommandLine); } } - else if (e.Key == Key.S && e.KeyModifiers.HasFlag(KeyModifiers.Control)) - { - _ = SaveAs(); - } } private void FocusSearch()