Polish launcher keyboard navigation
This commit is contained in:
@@ -13,6 +13,7 @@ Download the compiled Windows release from:
|
||||
- System tray launcher
|
||||
- Global hotkey, default `Ctrl+Alt+Space`
|
||||
- Search/filter in the launcher popup with parent menu context
|
||||
- Keyboard navigation in the launcher popup
|
||||
- Recent items section for quickly relaunching entries
|
||||
- Nested menus, drag/drop ordering, and drag/drop item creation in Settings
|
||||
- Right-click launcher entries to edit them in Settings
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
<Authors>Ray Berezowski</Authors>
|
||||
<ApplicationIcon>Assets\AppIcon.ico</ApplicationIcon>
|
||||
<Version>1.0.1</Version>
|
||||
<AssemblyVersion>1.0.1.14</AssemblyVersion>
|
||||
<FileVersion>1.0.1.14</FileVersion>
|
||||
<AssemblyVersion>1.0.1.15</AssemblyVersion>
|
||||
<FileVersion>1.0.1.15</FileVersion>
|
||||
<InformationalVersion>1.0.1</InformationalVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -164,19 +164,7 @@ public partial class LauncherPopup : Window
|
||||
button.ContextMenu = CreateItemContextMenu(item);
|
||||
}
|
||||
|
||||
button.KeyDown += (_, e) =>
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
launchItem(item);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Escape)
|
||||
{
|
||||
Close();
|
||||
e.Handled = true;
|
||||
}
|
||||
};
|
||||
button.KeyDown += LaunchButton_KeyDown;
|
||||
visibleLaunchButtons.Add(button);
|
||||
return button;
|
||||
}
|
||||
@@ -356,19 +344,7 @@ public partial class LauncherPopup : Window
|
||||
};
|
||||
|
||||
button.Click += (_, _) => launchItem(match.Item);
|
||||
button.KeyDown += (_, e) =>
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
launchItem(match.Item);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Escape)
|
||||
{
|
||||
Close();
|
||||
e.Handled = true;
|
||||
}
|
||||
};
|
||||
button.KeyDown += LaunchButton_KeyDown;
|
||||
|
||||
visibleLaunchButtons.Add(button);
|
||||
return button;
|
||||
@@ -437,14 +413,112 @@ public partial class LauncherPopup : Window
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Key.Down && visibleLaunchButtons.FirstOrDefault() is System.Windows.Controls.Button firstButton)
|
||||
if (e.Key == Key.Down)
|
||||
{
|
||||
Keyboard.ClearFocus();
|
||||
firstButton.Focus();
|
||||
FocusLaunchButton(0);
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Key.Up)
|
||||
{
|
||||
FocusLaunchButton(visibleLaunchButtons.Count - 1);
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Key.Home)
|
||||
{
|
||||
SearchBox.CaretIndex = 0;
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Key.End)
|
||||
{
|
||||
SearchBox.CaretIndex = SearchBox.Text.Length;
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void LaunchButton_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
||||
{
|
||||
if (sender is not System.Windows.Controls.Button button)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Key.Enter && button.Tag is LauncherItem item)
|
||||
{
|
||||
launchItem(item);
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
Close();
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
int index = visibleLaunchButtons.IndexOf(button);
|
||||
if (index < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Key.Down)
|
||||
{
|
||||
FocusLaunchButton(index + 1);
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Key.Up)
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
SearchBox.Focus();
|
||||
SearchBox.CaretIndex = SearchBox.Text.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
FocusLaunchButton(index - 1);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Key.Home)
|
||||
{
|
||||
FocusLaunchButton(0);
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Key == Key.End)
|
||||
{
|
||||
FocusLaunchButton(visibleLaunchButtons.Count - 1);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void FocusLaunchButton(int index)
|
||||
{
|
||||
if (visibleLaunchButtons.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int clampedIndex = Math.Clamp(index, 0, visibleLaunchButtons.Count - 1);
|
||||
System.Windows.Controls.Button button = visibleLaunchButtons[clampedIndex];
|
||||
Keyboard.ClearFocus();
|
||||
button.Focus();
|
||||
button.BringIntoView();
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(System.Windows.Input.KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
|
||||
@@ -28,6 +28,8 @@ Recently launched entries appear in the launcher popup under **Recent**.
|
||||
|
||||
Search results include the parent menu path when an item is inside a menu.
|
||||
|
||||
Use arrow keys, Home, End, Enter, and Escape to navigate the launcher popup from the keyboard.
|
||||
|
||||
## Configure
|
||||
|
||||
Open the tray menu and choose **Settings**.
|
||||
|
||||
Reference in New Issue
Block a user