Skip to content

Commit b9b3422

Browse files
authored
Merge pull request #2697 from onesounds/240516BlockHoverWhenKeyboardUsing
Block Mouse Hover event when Show / Keyboard Navigation
2 parents 106760c + be1c3f7 commit b9b3422

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Flow.Launcher/MainWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
LocationChanged="OnLocationChanged"
2626
Opacity="{Binding MainWindowOpacity, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
2727
PreviewKeyDown="OnKeyDown"
28+
PreviewKeyUp="OnKeyUp"
2829
ResizeMode="NoResize"
2930
ShowInTaskbar="False"
3031
SizeToContent="Height"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public partial class MainWindow
4747
private MainViewModel _viewModel;
4848
private bool _animating;
4949
MediaPlayer animationSound = new MediaPlayer();
50+
private bool isArrowKeyPressed = false;
5051

5152
#endregion
5253

@@ -109,9 +110,11 @@ private async void OnClosing(object sender, CancelEventArgs e)
109110
private void OnInitialized(object sender, EventArgs e)
110111
{
111112
}
112-
113113
private void OnLoaded(object sender, RoutedEventArgs _)
114114
{
115+
// MouseEventHandler
116+
PreviewMouseMove += MainPreviewMouseMove;
117+
115118
CheckFirstLaunch();
116119
HideStartup();
117120
// show notify icon when flowlauncher is hidden
@@ -406,6 +409,7 @@ public void WindowAnimator()
406409
if (_animating)
407410
return;
408411

412+
isArrowKeyPressed = true;
409413
_animating = true;
410414
UpdatePosition();
411415

@@ -494,6 +498,7 @@ public void WindowAnimator()
494498
windowsb.Completed += (_, _) => _animating = false;
495499
_settings.WindowLeft = Left;
496500
_settings.WindowTop = Top;
501+
isArrowKeyPressed = false;
497502

498503
if (QueryTextBox.Text.Length == 0)
499504
{
@@ -644,10 +649,12 @@ private void OnKeyDown(object sender, KeyEventArgs e)
644649
switch (e.Key)
645650
{
646651
case Key.Down:
652+
isArrowKeyPressed = true;
647653
_viewModel.SelectNextItemCommand.Execute(null);
648654
e.Handled = true;
649655
break;
650656
case Key.Up:
657+
isArrowKeyPressed = true;
651658
_viewModel.SelectPrevItemCommand.Execute(null);
652659
e.Handled = true;
653660
break;
@@ -698,7 +705,21 @@ private void OnKeyDown(object sender, KeyEventArgs e)
698705

699706
}
700707
}
708+
private void OnKeyUp(object sender, KeyEventArgs e)
709+
{
710+
if (e.Key == Key.Up || e.Key == Key.Down)
711+
{
712+
isArrowKeyPressed = false;
713+
}
714+
}
701715

716+
private void MainPreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
717+
{
718+
if (isArrowKeyPressed)
719+
{
720+
e.Handled = true; // Ignore Mouse Hover when press Arrowkeys
721+
}
722+
}
702723
public void PreviewReset()
703724
{
704725
_viewModel.ResetPreview();

0 commit comments

Comments
 (0)