[PT Run] Fix some keyboard issues on plugin (#13490)

* Don't use enter for accelerator keys in results

Enter is already used to select commands in the context menu in the
result entries.

* Don't crash when trying to show a tooltip

* Clear hanging tooltips when keyboard navigating

* Starting/stopping service on Enter
This commit is contained in:
Jaime Bernardo
2021-09-28 15:30:44 +01:00
committed by GitHub
parent 7874b77104
commit c85fa98bcc
4 changed files with 54 additions and 16 deletions

View File

@@ -58,14 +58,25 @@ namespace PowerLauncher
if (listView.SelectedItem != null)
{
ListBoxItem listBoxItem = (ListBoxItem)listView.ItemContainerGenerator.ContainerFromItem(listView.SelectedItem);
ContentPresenter contentPresenter = FindVisualChild<ContentPresenter>(listBoxItem);
DataTemplate dataTemplate = contentPresenter.ContentTemplate;
Button button = (Button)dataTemplate.FindName("commandButton", contentPresenter);
ToolTip tooltip = button.ToolTip as ToolTip;
tooltip.PlacementTarget = button;
tooltip.Placement = System.Windows.Controls.Primitives.PlacementMode.Right;
tooltip.PlacementRectangle = new Rect(0, button.Height, 0, 0);
tooltip.IsOpen = true;
if (listBoxItem != null)
{
ContentPresenter contentPresenter = FindVisualChild<ContentPresenter>(listBoxItem);
DataTemplate dataTemplate = contentPresenter.ContentTemplate;
Button button = (Button)dataTemplate.FindName("commandButton", contentPresenter);
ToolTip tooltip = button.ToolTip as ToolTip;
tooltip.PlacementTarget = button;
tooltip.Placement = System.Windows.Controls.Primitives.PlacementMode.Right;
tooltip.PlacementRectangle = new Rect(0, button.Height, 0, 0);
tooltip.IsOpen = true;
}
else
{
HideCurrentToolTip();
}
}
else
{
HideCurrentToolTip();
}
}