fix: Ctrl+F is not working when Welcome page is not focused (#398)

This commit is contained in:
leo 2024-08-23 17:05:13 +08:00
parent c76d521f12
commit e845c270cd
No known key found for this signature in database
2 changed files with 14 additions and 7 deletions

View file

@ -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<Welcome>();
if (welcome != null)
{
if (e.Key == Key.F)
{
welcome.SearchBox.Focus();
e.Handled = true;
return;
}
}
}
}
else if (e.Key == Key.Escape)
{

View file

@ -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();