From e845c270cd62503df593aa6e87e77acf3168f929 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 23 Aug 2024 17:05:13 +0800 Subject: [PATCH] fix: `Ctrl+F` is not working when Welcome page is not focused (#398) --- src/Views/Launcher.axaml.cs | 14 ++++++++++++++ src/Views/Welcome.axaml.cs | 7 ------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Views/Launcher.axaml.cs b/src/Views/Launcher.axaml.cs index aa184cf2..4b5b2889 100644 --- a/src/Views/Launcher.axaml.cs +++ b/src/Views/Launcher.axaml.cs @@ -3,6 +3,7 @@ using System; using Avalonia; using Avalonia.Controls; using Avalonia.Input; +using Avalonia.VisualTree; namespace SourceGit.Views { @@ -160,6 +161,19 @@ namespace SourceGit.Views return; } } + else + { + var welcome = this.FindDescendantOfType(); + if (welcome != null) + { + if (e.Key == Key.F) + { + welcome.SearchBox.Focus(); + e.Handled = true; + return; + } + } + } } else if (e.Key == Key.Escape) { diff --git a/src/Views/Welcome.axaml.cs b/src/Views/Welcome.axaml.cs index e4a329e8..9e887ab0 100644 --- a/src/Views/Welcome.axaml.cs +++ b/src/Views/Welcome.axaml.cs @@ -45,13 +45,6 @@ namespace SourceGit.Views TreeContainer.Focus(NavigationMethod.Directional); e.Handled = true; } - else if (e.Key == Key.F && - ((OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Meta)) || - (!OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Control)))) - { - SearchBox.Focus(); - e.Handled = true; - } else if (e.Key == Key.Escape) { ViewModels.Welcome.Instance.ClearSearchFilter();