|
|
@ -42,9 +42,8 @@ namespace Avalonia.Input |
|
|
RoutedEvent.Register<PointerDeltaEventArgs>( |
|
|
RoutedEvent.Register<PointerDeltaEventArgs>( |
|
|
"PointerSwipeGesture", RoutingStrategies.Bubble, typeof(Gestures)); |
|
|
"PointerSwipeGesture", RoutingStrategies.Bubble, typeof(Gestures)); |
|
|
|
|
|
|
|
|
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
|
|
|
private static readonly WeakReference<IInteractive?> s_lastPress = new WeakReference<IInteractive?>(null); |
|
|
private static readonly WeakReference<IInteractive> s_lastPress = new WeakReference<IInteractive>(null); |
|
|
private static Point s_lastPressPoint; |
|
|
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
|
|
|
|
|
|
|
|
|
|
|
|
static Gestures() |
|
|
static Gestures() |
|
|
{ |
|
|
{ |
|
|
@ -98,6 +97,7 @@ namespace Avalonia.Input |
|
|
{ |
|
|
{ |
|
|
s_isDoubleTapped = false; |
|
|
s_isDoubleTapped = false; |
|
|
s_lastPress.SetTarget(ev.Source); |
|
|
s_lastPress.SetTarget(ev.Source); |
|
|
|
|
|
s_lastPressPoint = e.GetPosition((IVisual)ev.Source); |
|
|
} |
|
|
} |
|
|
else if (e.ClickCount % 2 == 0 && e.GetCurrentPoint(visual).Properties.IsLeftButtonPressed) |
|
|
else if (e.ClickCount % 2 == 0 && e.GetCurrentPoint(visual).Properties.IsLeftButtonPressed) |
|
|
{ |
|
|
{ |
|
|
@ -120,9 +120,16 @@ namespace Avalonia.Input |
|
|
{ |
|
|
{ |
|
|
var e = (PointerReleasedEventArgs)ev; |
|
|
var e = (PointerReleasedEventArgs)ev; |
|
|
|
|
|
|
|
|
if (s_lastPress.TryGetTarget(out var target) && target == e.Source) |
|
|
if (s_lastPress.TryGetTarget(out var target) && |
|
|
|
|
|
target == e.Source && |
|
|
|
|
|
e.InitialPressMouseButton is MouseButton.Left or MouseButton.Right) |
|
|
{ |
|
|
{ |
|
|
if (e.InitialPressMouseButton == MouseButton.Left || e.InitialPressMouseButton == MouseButton.Right) |
|
|
var point = e.GetCurrentPoint((IVisual)target); |
|
|
|
|
|
var tapSize = new Size(4, 4); |
|
|
|
|
|
var tapRect = new Rect(s_lastPressPoint, new Size()) |
|
|
|
|
|
.Inflate(new Thickness(tapSize.Width, tapSize.Height)); |
|
|
|
|
|
|
|
|
|
|
|
if (tapRect.ContainsExclusive(point.Position)) |
|
|
{ |
|
|
{ |
|
|
if (e.InitialPressMouseButton == MouseButton.Right) |
|
|
if (e.InitialPressMouseButton == MouseButton.Right) |
|
|
{ |
|
|
{ |
|
|
|