feature: support using left/right arrow to expand/collapse tree node (#463)

This commit is contained in:
leo 2024-09-22 20:48:36 +08:00
parent 01380ff194
commit 07cba1cf5f
No known key found for this signature in database
5 changed files with 82 additions and 37 deletions

View file

@ -25,6 +25,26 @@ namespace SourceGit.Views
e.Handled = true;
}
}
public class RepositoryListBox : ListBox
{
protected override Type StyleKeyOverride => typeof(ListBox);
protected override void OnKeyDown(KeyEventArgs e)
{
if (SelectedItems is [ViewModels.RepositoryNode { IsRepository: false } node] && e.KeyModifiers == KeyModifiers.None)
{
if ((node.IsExpanded && e.Key == Key.Left) || (!node.IsExpanded && e.Key == Key.Right))
{
ViewModels.Welcome.Instance.ToggleNodeIsExpanded(node);
e.Handled = true;
}
}
if (!e.Handled)
base.OnKeyDown(e);
}
}
public partial class Welcome : UserControl
{