-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathBlameCommandPalette.axaml.cs
More file actions
63 lines (56 loc) · 1.73 KB
/
BlameCommandPalette.axaml.cs
File metadata and controls
63 lines (56 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using Avalonia.Controls;
using Avalonia.Input;
namespace SourceGit.Views
{
public partial class BlameCommandPalette : UserControl
{
public BlameCommandPalette()
{
InitializeComponent();
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (DataContext is not ViewModels.BlameCommandPalette vm)
return;
if (e.Key == Key.Enter)
{
this.ShowWindow(vm.Launch());
e.Handled = true;
}
else if (e.Key == Key.Up)
{
if (FileListBox.IsKeyboardFocusWithin)
{
FilterTextBox.Focus(NavigationMethod.Directional);
e.Handled = true;
return;
}
}
else if (e.Key == Key.Down || e.Key == Key.Tab)
{
if (FilterTextBox.IsKeyboardFocusWithin)
{
if (vm.VisibleFiles.Count > 0)
FileListBox.Focus(NavigationMethod.Directional);
e.Handled = true;
return;
}
if (FileListBox.IsKeyboardFocusWithin && e.Key == Key.Tab)
{
FilterTextBox.Focus(NavigationMethod.Directional);
e.Handled = true;
return;
}
}
}
private void OnItemTapped(object sender, TappedEventArgs e)
{
if (DataContext is ViewModels.BlameCommandPalette vm)
{
this.ShowWindow(vm.Launch());
e.Handled = true;
}
}
}
}