Skip to content

Commit

Permalink
(chocolateyGH-356) Fix Codacy/PR Quality Review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Apr 26, 2019
1 parent 1eded49 commit 757b1fd
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Source/ChocolateyGui/Utilities/BubbleScrollEventBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,30 @@ public class BubbleScrollEventBehavior : Behavior<UIElement>
protected override void OnAttached()
{
base.OnAttached();

AssociatedObject.PreviewMouseWheel -= AssociatedObject_PreviewMouseWheel;
AssociatedObject.PreviewMouseWheel += AssociatedObject_PreviewMouseWheel;
}

protected override void OnDetaching()
{
AssociatedObject.PreviewMouseWheel -= AssociatedObject_PreviewMouseWheel;

base.OnDetaching();
}

private void AssociatedObject_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (!Keyboard.IsKeyDown(Key.LeftShift))
var uiElement = sender as UIElement;
if (uiElement == null || Keyboard.IsKeyDown(Key.LeftShift))
{
e.Handled = true;
var e2 = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) { RoutedEvent = UIElement.MouseWheelEvent };
AssociatedObject.RaiseEvent(e2);
return;
}

e.Handled = true;

var e2 = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) { RoutedEvent = UIElement.MouseWheelEvent };
uiElement.RaiseEvent(e2);
}
}
}

0 comments on commit 757b1fd

Please sign in to comment.