mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
Added functionality for left/right key navigation (#5067)
* Added functionality for left/right key navigation * Update Behviour of left/right navigation * Code cleanup * Null check for results VM * Added tests for results view model * Update test namings
This commit is contained in:
committed by
GitHub
parent
25d43354b3
commit
f773604dec
@@ -239,6 +239,25 @@ namespace PowerLauncher
|
||||
UpdateTextBoxToSelectedItem();
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Right)
|
||||
{
|
||||
if(SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length)
|
||||
{
|
||||
_viewModel.SelectNextContextMenuItemCommand.Execute(null);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
else if (e.Key == Key.Left)
|
||||
{
|
||||
if (SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length)
|
||||
{
|
||||
if(_viewModel.Results != null && _viewModel.Results.IsContextMenuItemSelected())
|
||||
{
|
||||
_viewModel.SelectPreviousContextMenuItemCommand.Execute(null);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.Key == Key.PageDown)
|
||||
{
|
||||
_viewModel.SelectNextPageCommand.Execute(null);
|
||||
|
||||
@@ -151,6 +151,16 @@ namespace PowerLauncher.ViewModel
|
||||
SelectedResults.SelectPrevTabItem();
|
||||
});
|
||||
|
||||
SelectNextContextMenuItemCommand = new RelayCommand(_ =>
|
||||
{
|
||||
SelectedResults.SelectNextContextMenuItem();
|
||||
});
|
||||
|
||||
SelectPreviousContextMenuItemCommand = new RelayCommand(_ =>
|
||||
{
|
||||
SelectedResults.SelectPreviousContextMenuItem();
|
||||
});
|
||||
|
||||
SelectNextPageCommand = new RelayCommand(_ =>
|
||||
{
|
||||
SelectedResults.SelectNextPage();
|
||||
@@ -342,6 +352,8 @@ namespace PowerLauncher.ViewModel
|
||||
public ICommand EscCommand { get; set; }
|
||||
public ICommand SelectNextItemCommand { get; set; }
|
||||
public ICommand SelectPrevItemCommand { get; set; }
|
||||
public ICommand SelectNextContextMenuItemCommand { get; set; }
|
||||
public ICommand SelectPreviousContextMenuItemCommand { get; set; }
|
||||
|
||||
public ICommand SelectNextTabItemCommand { get; set; }
|
||||
public ICommand SelectPrevTabItemCommand { get; set; }
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace PowerLauncher.ViewModel
|
||||
|
||||
public int ContextMenuSelectedIndex { get; set; }
|
||||
|
||||
const int NoSelectionIndex = -1;
|
||||
public const int NoSelectionIndex = -1;
|
||||
|
||||
public ResultViewModel(Result result)
|
||||
{
|
||||
|
||||
@@ -180,6 +180,37 @@ namespace PowerLauncher.ViewModel
|
||||
SelectPrevResult();
|
||||
SelectedItem.SelectLastContextButton();
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectNextContextMenuItem()
|
||||
{
|
||||
if(SelectedItem != null)
|
||||
{
|
||||
if(!SelectedItem.SelectNextContextButton())
|
||||
{
|
||||
SelectedItem.SelectLastContextButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectPreviousContextMenuItem()
|
||||
{
|
||||
if (SelectedItem != null)
|
||||
{
|
||||
SelectedItem.SelectPrevContextButton();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsContextMenuItemSelected()
|
||||
{
|
||||
if (SelectedItem != null && SelectedItem.ContextMenuSelectedIndex != ResultViewModel.NoSelectionIndex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -205,8 +236,8 @@ namespace PowerLauncher.ViewModel
|
||||
Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<ResultViewModel> NewResults(List<Result> newRawResults, string resultId)
|
||||
{
|
||||
var results = Results.ToList();
|
||||
|
||||
Reference in New Issue
Block a user