Browse Source

remove hold styled properties in InputElement

pull/9652/head
Emmanuel Hansen 3 years ago
parent
commit
66ca4ca639
  1. 2
      src/Avalonia.Base/Input/Gestures.cs
  2. 31
      src/Avalonia.Base/Input/InputElement.cs
  3. 12
      tests/Avalonia.Base.UnitTests/Input/GesturesTests.cs

2
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));

31
src/Avalonia.Base/Input/InputElement.cs

@ -198,18 +198,6 @@ namespace Avalonia.Input
/// </summary>
public static readonly RoutedEvent<TappedEventArgs> DoubleTappedEvent = Gestures.DoubleTappedEvent;
/// <summary>
/// Defines the <see cref="IsHoldingEnabled"/> property.
/// </summary>
public static readonly StyledProperty<bool> IsHoldingEnabledProperty =
Gestures.IsHoldingEnabledProperty.AddOwner<InputElement>();
/// <summary>
/// Defines the <see cref="IsHoldWithMouseEnabled"/> property.
/// </summary>
public static readonly StyledProperty<bool> IsHoldWithMouseEnabledProperty =
Gestures.IsHoldWithMouseEnabledProperty.AddOwner<InputElement>();
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); }
}
/// <summary>
/// Gets or sets a value that determines whether the Holding event can originate
/// from that element.
/// </summary>
public bool IsHoldingEnabled
{
get { return GetValue(IsHoldingEnabledProperty); }
set { SetValue(IsHoldingEnabledProperty, value); }
}
/// <summary>
/// Enables or disables support for the press and hold gesture through the left button on a mouse.
/// </summary>
public bool IsHoldWithMouseEnabled
{
get { return GetValue(IsHoldWithMouseEnabledProperty); }
set { SetValue(IsHoldWithMouseEnabledProperty, value); }
}
/// <summary>
/// Gets a value indicating whether keyboard focus is anywhere within the element or its visual tree child elements.

12
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

Loading…
Cancel
Save