From 66ca4ca6399f964c30e09672aca42fb7d016b106 Mon Sep 17 00:00:00 2001 From: Emmanuel Hansen Date: Wed, 28 Dec 2022 08:55:21 +0000 Subject: [PATCH] remove hold styled properties in InputElement --- src/Avalonia.Base/Input/Gestures.cs | 2 +- src/Avalonia.Base/Input/InputElement.cs | 31 ------------------- .../Input/GesturesTests.cs | 12 +++---- 3 files changed, 7 insertions(+), 38 deletions(-) diff --git a/src/Avalonia.Base/Input/Gestures.cs b/src/Avalonia.Base/Input/Gestures.cs index 9708ca2b48..54e61d89b2 100644 --- a/src/Avalonia.Base/Input/Gestures.cs +++ b/src/Avalonia.Base/Input/Gestures.cs @@ -183,7 +183,7 @@ namespace Avalonia.Input { DispatcherTimer.RunOnce(() => { - if (!token.IsCancellationRequested && e.Source is InputElement i && i.IsHoldingEnabled && (e.Pointer.Type != PointerType.Mouse || i.IsHoldWithMouseEnabled)) + if (!token.IsCancellationRequested && e.Source is InputElement i && GetIsHoldingEnabled(i) && (e.Pointer.Type != PointerType.Mouse || GetIsHoldWithMouseEnabled(i))) { s_isHolding = true; i.RaiseEvent(new HoldingRoutedEventArgs(HoldingState.Started, s_lastPressPoint, s_lastPointer.Type)); diff --git a/src/Avalonia.Base/Input/InputElement.cs b/src/Avalonia.Base/Input/InputElement.cs index e1835241bf..f233fdce51 100644 --- a/src/Avalonia.Base/Input/InputElement.cs +++ b/src/Avalonia.Base/Input/InputElement.cs @@ -198,18 +198,6 @@ namespace Avalonia.Input /// public static readonly RoutedEvent DoubleTappedEvent = Gestures.DoubleTappedEvent; - /// - /// Defines the property. - /// - public static readonly StyledProperty IsHoldingEnabledProperty = - Gestures.IsHoldingEnabledProperty.AddOwner(); - - /// - /// Defines the property. - /// - public static readonly StyledProperty IsHoldWithMouseEnabledProperty = - Gestures.IsHoldWithMouseEnabledProperty.AddOwner(); - private bool _isEffectivelyEnabled = true; private bool _isFocused; private bool _isKeyboardFocusWithin; @@ -414,25 +402,6 @@ namespace Avalonia.Input get { return GetValue(CursorProperty); } set { SetValue(CursorProperty, value); } } - - /// - /// Gets or sets a value that determines whether the Holding event can originate - /// from that element. - /// - public bool IsHoldingEnabled - { - get { return GetValue(IsHoldingEnabledProperty); } - set { SetValue(IsHoldingEnabledProperty, value); } - } - - /// - /// Enables or disables support for the press and hold gesture through the left button on a mouse. - /// - public bool IsHoldWithMouseEnabled - { - get { return GetValue(IsHoldWithMouseEnabledProperty); } - set { SetValue(IsHoldWithMouseEnabledProperty, value); } - } /// /// Gets a value indicating whether keyboard focus is anywhere within the element or its visual tree child elements. diff --git a/tests/Avalonia.Base.UnitTests/Input/GesturesTests.cs b/tests/Avalonia.Base.UnitTests/Input/GesturesTests.cs index 1b0c941082..84ee35ba61 100644 --- a/tests/Avalonia.Base.UnitTests/Input/GesturesTests.cs +++ b/tests/Avalonia.Base.UnitTests/Input/GesturesTests.cs @@ -188,7 +188,7 @@ namespace Avalonia.Base.UnitTests.Input threadingInterface: CreatePlatformThreadingInterface(t => scheduledTimers.Add(t)))); Border border = new Border(); - border.IsHoldWithMouseEnabled = true; + Gestures.SetIsHoldWithMouseEnabled(border, true); var decorator = new Decorator { Child = border @@ -226,7 +226,7 @@ namespace Avalonia.Base.UnitTests.Input threadingInterface: CreatePlatformThreadingInterface(t => scheduledTimers.Add(t)))); Border border = new Border(); - border.IsHoldWithMouseEnabled = true; + Gestures.SetIsHoldWithMouseEnabled(border, true); var decorator = new Decorator { Child = border @@ -263,7 +263,7 @@ namespace Avalonia.Base.UnitTests.Input threadingInterface: CreatePlatformThreadingInterface(t => scheduledTimers.Add(t)))); Border border = new Border(); - border.IsHoldWithMouseEnabled = true; + Gestures.SetIsHoldWithMouseEnabled(border, true); var decorator = new Decorator { Child = border @@ -300,7 +300,7 @@ namespace Avalonia.Base.UnitTests.Input threadingInterface: CreatePlatformThreadingInterface(t => scheduledTimers.Add(t)))); Border border = new Border(); - border.IsHoldWithMouseEnabled = true; + Gestures.SetIsHoldWithMouseEnabled(border, true); var decorator = new Decorator { Child = border @@ -338,7 +338,7 @@ namespace Avalonia.Base.UnitTests.Input threadingInterface: CreatePlatformThreadingInterface(t => scheduledTimers.Add(t)))); Border border = new Border(); - border.IsHoldWithMouseEnabled = true; + Gestures.SetIsHoldWithMouseEnabled(border, true); var decorator = new Decorator { Child = border @@ -376,7 +376,7 @@ namespace Avalonia.Base.UnitTests.Input threadingInterface: CreatePlatformThreadingInterface(t => scheduledTimers.Add(t)))); Border border = new Border(); - border.IsHoldWithMouseEnabled = true; + Gestures.SetIsHoldWithMouseEnabled(border, true); var decorator = new Decorator { Child = border