Skip to content

Commit 5a7ca5a

Browse files
authored
Merge pull request #56 from jholzer/FeatureOptinallyDisableMouseWheel
Feature optionally disable mouse wheel
2 parents 2b3bd4a + 591e4cc commit 5a7ca5a

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

source/NumericUpDownLib/Base/AbstractBaseUpDown.cs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,15 @@ public abstract partial class AbstractBaseUpDown<T> : InputBaseUpDown, ICommandS
176176
DependencyProperty.Register("CanMouseDrag", typeof(CanIncDecMouseDrag),
177177
typeof(AbstractBaseUpDown<T>), new PropertyMetadata(CanIncDecMouseDrag.VerticalHorizontal));
178178

179+
public static readonly DependencyProperty MouseWheelEnabledProperty =
180+
DependencyProperty.Register("MouseWheelEnabled", typeof(bool),
181+
typeof(AbstractBaseUpDown<T>),
182+
new PropertyMetadata(true));
179183

180-
/// <summary>
181-
/// Backing store of <see cref="IsLargeStepEnabled"/> dependency property.
182-
/// </summary>
183-
public static readonly DependencyProperty IsLargeStepEnabledProperty =
184+
/// <summary>
185+
/// Backing store of <see cref="IsLargeStepEnabled"/> dependency property.
186+
/// </summary>
187+
public static readonly DependencyProperty IsLargeStepEnabledProperty =
184188
DependencyProperty.Register("IsLargeStepEnabled", typeof(bool),
185189
typeof(AbstractBaseUpDown<T>), new PropertyMetadata(true));
186190

@@ -526,11 +530,16 @@ public CanIncDecMouseDrag CanMouseDrag
526530
set { SetValue(CanMouseDragProperty, value); }
527531
}
528532

533+
public bool MouseWheelEnabled
534+
{
535+
get { return (bool)GetValue(MouseWheelEnabledProperty); }
536+
set { SetValue(MouseWheelEnabledProperty, value); }
537+
}
529538

530-
/// <summary>
531-
/// Gets/sets wether enable large step Increment/Decrement
532-
/// </summary>
533-
public bool IsLargeStepEnabled
539+
/// <summary>
540+
/// Gets/sets wether enable large step Increment/Decrement
541+
/// </summary>
542+
public bool IsLargeStepEnabled
534543
{
535544
get { return (bool)GetValue(IsLargeStepEnabledProperty); }
536545
set { SetValue(IsLargeStepEnabledProperty, value); }
@@ -670,7 +679,9 @@ protected override void OnMouseWheel(MouseWheelEventArgs e)
670679
{
671680
base.OnMouseWheel(e);
672681

673-
if (e.Handled == false)
682+
if (!MouseWheelEnabled)
683+
return;
684+
if (e.Handled == false)
674685
{
675686
if (e.Delta != 0)
676687
{
@@ -1440,4 +1451,4 @@ private static void OnIsDisplayLengthFixedChanged(DependencyObject d, Dependency
14401451
#endregion DisplayLength IsDisplayLengthFixed
14411452
#endregion methods DisplayLength IsDisplayLengthFixed
14421453
}
1443-
}
1454+
}

0 commit comments

Comments
 (0)