diff --git a/Flow.Launcher.Test/Flow.Launcher.Test.csproj b/Flow.Launcher.Test/Flow.Launcher.Test.csproj index 11ccff05b05..9ade234c79f 100644 --- a/Flow.Launcher.Test/Flow.Launcher.Test.csproj +++ b/Flow.Launcher.Test/Flow.Launcher.Test.csproj @@ -39,6 +39,7 @@ + diff --git a/Flow.Launcher.Test/MouseWheelTest.cs b/Flow.Launcher.Test/MouseWheelTest.cs new file mode 100644 index 00000000000..eb827293bb6 --- /dev/null +++ b/Flow.Launcher.Test/MouseWheelTest.cs @@ -0,0 +1,36 @@ +using System; +using System.Reflection; +using System.Windows; +using System.Windows.Input; +using System.Windows.Interop; +using Flow.Launcher.Resources.Controls; +using NUnit.Framework; + +namespace Flow.Launcher.Test; + +[TestFixture] +public class MouseWheelTest +{ + [Test] + [RequiresThread(System.Threading.ApartmentState.STA)] + public void Test_Scroll_MouseWheel() + { + var scrollView = new CustomScrollViewerEx(); + + var mouseDevice = Mouse.PrimaryDevice; + var e = new MouseWheelEventArgs(mouseDevice, Environment.TickCount, 120) + { + RoutedEvent = UIElement.MouseWheelEvent + }; + + var onMouseWheelMethod = typeof(CustomScrollViewerEx).GetMethod( + "OnMouseWheel", + BindingFlags.NonPublic | BindingFlags.Instance + ); + + Assert.DoesNotThrow(() => + { + onMouseWheelMethod.Invoke(scrollView, new object[] { e }); + }); + } +} diff --git a/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs b/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs index 78985108ce2..fbc85e223cb 100644 --- a/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs +++ b/Flow.Launcher/Resources/Controls/CustomScrollViewerEx.cs @@ -44,8 +44,7 @@ public Orientation Orientation #region AutoHideScrollBars public static readonly DependencyProperty AutoHideScrollBarsProperty = - ScrollViewerHelper.AutoHideScrollBarsProperty - .AddOwner( + ScrollViewerHelper.AutoHideScrollBarsProperty.AddOwner( typeof(CustomScrollViewerEx), new PropertyMetadata(true, OnAutoHideScrollBarsChanged)); @@ -86,6 +85,9 @@ protected override void OnInitialized(EventArgs e) /// protected override void OnMouseWheel(MouseWheelEventArgs e) { + if (ActualHeight <= 0) + return; + var Direction = GetDirection(); ScrollViewerBehavior.SetIsAnimating(this, true);