/
vasiukoff
/
sg
Обзор
Документация
Войти
/
vasiukoff
/
sg
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/Views/OpenFileCommandPalette.axaml.cs
63 строки
2 KB
leo
refactor: command palette auto-selection (#1937)
26 ноя 2025, 09:50
26 ноя 2025, 09:50
e7bd7bb
Код
Авторство
О чём код?
using Avalonia.Controls; using Avalonia.Input; namespace SourceGit.Views { public partial class OpenFileCommandPalette : UserControl { public OpenFileCommandPalette() { InitializeComponent(); } protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); if (DataContext is not ViewModels.OpenFileCommandPalette vm) return; if (e.Key == Key.Enter) { 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.OpenFileCommandPalette vm) { vm.Launch(); e.Handled = true; } } } }