Polish launcher keyboard navigation
This commit is contained in:
@@ -13,6 +13,7 @@ Download the compiled Windows release from:
|
|||||||
- System tray launcher
|
- System tray launcher
|
||||||
- Global hotkey, default `Ctrl+Alt+Space`
|
- Global hotkey, default `Ctrl+Alt+Space`
|
||||||
- Search/filter in the launcher popup with parent menu context
|
- Search/filter in the launcher popup with parent menu context
|
||||||
|
- Keyboard navigation in the launcher popup
|
||||||
- Recent items section for quickly relaunching entries
|
- Recent items section for quickly relaunching entries
|
||||||
- Nested menus, drag/drop ordering, and drag/drop item creation in Settings
|
- Nested menus, drag/drop ordering, and drag/drop item creation in Settings
|
||||||
- Right-click launcher entries to edit them in Settings
|
- Right-click launcher entries to edit them in Settings
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
<Authors>Ray Berezowski</Authors>
|
<Authors>Ray Berezowski</Authors>
|
||||||
<ApplicationIcon>Assets\AppIcon.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\AppIcon.ico</ApplicationIcon>
|
||||||
<Version>1.0.1</Version>
|
<Version>1.0.1</Version>
|
||||||
<AssemblyVersion>1.0.1.14</AssemblyVersion>
|
<AssemblyVersion>1.0.1.15</AssemblyVersion>
|
||||||
<FileVersion>1.0.1.14</FileVersion>
|
<FileVersion>1.0.1.15</FileVersion>
|
||||||
<InformationalVersion>1.0.1</InformationalVersion>
|
<InformationalVersion>1.0.1</InformationalVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -164,19 +164,7 @@ public partial class LauncherPopup : Window
|
|||||||
button.ContextMenu = CreateItemContextMenu(item);
|
button.ContextMenu = CreateItemContextMenu(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
button.KeyDown += (_, e) =>
|
button.KeyDown += LaunchButton_KeyDown;
|
||||||
{
|
|
||||||
if (e.Key == Key.Enter)
|
|
||||||
{
|
|
||||||
launchItem(item);
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
else if (e.Key == Key.Escape)
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
visibleLaunchButtons.Add(button);
|
visibleLaunchButtons.Add(button);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
@@ -356,19 +344,7 @@ public partial class LauncherPopup : Window
|
|||||||
};
|
};
|
||||||
|
|
||||||
button.Click += (_, _) => launchItem(match.Item);
|
button.Click += (_, _) => launchItem(match.Item);
|
||||||
button.KeyDown += (_, e) =>
|
button.KeyDown += LaunchButton_KeyDown;
|
||||||
{
|
|
||||||
if (e.Key == Key.Enter)
|
|
||||||
{
|
|
||||||
launchItem(match.Item);
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
else if (e.Key == Key.Escape)
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
visibleLaunchButtons.Add(button);
|
visibleLaunchButtons.Add(button);
|
||||||
return button;
|
return button;
|
||||||
@@ -437,14 +413,112 @@ public partial class LauncherPopup : Window
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.Key == Key.Down && visibleLaunchButtons.FirstOrDefault() is System.Windows.Controls.Button firstButton)
|
if (e.Key == Key.Down)
|
||||||
{
|
{
|
||||||
Keyboard.ClearFocus();
|
FocusLaunchButton(0);
|
||||||
firstButton.Focus();
|
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;
|
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)
|
protected override void OnKeyDown(System.Windows.Input.KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Escape)
|
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.
|
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
|
## Configure
|
||||||
|
|
||||||
Open the tray menu and choose **Settings**.
|
Open the tray menu and choose **Settings**.
|
||||||
|
|||||||
Reference in New Issue
Block a user