|
|
@ -58,9 +58,7 @@ namespace Avalonia.Input |
|
|
|
|
|
|
|
|
private void CaptureLostCore(CaptureSource source) |
|
|
private void CaptureLostCore(CaptureSource source) |
|
|
{ |
|
|
{ |
|
|
if (Captured != null) |
|
|
CaptureCore(null, null, source); |
|
|
CaptureCore(null, source); |
|
|
|
|
|
CaptureGestureRecognizerCore(null); |
|
|
|
|
|
IsGestureRecognitionSkipped = false; |
|
|
IsGestureRecognitionSkipped = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -69,6 +67,8 @@ namespace Avalonia.Input |
|
|
Capture(control, CaptureSource.Explicit); |
|
|
Capture(control, CaptureSource.Explicit); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private IInputElement? EffectiveCapturer => this.CapturedGestureRecognizer?.Target ?? Captured; |
|
|
|
|
|
|
|
|
internal void Capture(IInputElement? control, CaptureSource source) |
|
|
internal void Capture(IInputElement? control, CaptureSource source) |
|
|
{ |
|
|
{ |
|
|
if (_disposed) |
|
|
if (_disposed) |
|
|
@ -77,16 +77,21 @@ namespace Avalonia.Input |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
CaptureCore(control, source); |
|
|
CaptureCore(control, null, source); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void CaptureCore(IInputElement? control, CaptureSource source) |
|
|
private void CaptureCore( |
|
|
|
|
|
IInputElement? control, |
|
|
|
|
|
GestureRecognizer? gestureRecognizer, |
|
|
|
|
|
CaptureSource source) |
|
|
{ |
|
|
{ |
|
|
var oldCapture = Captured; |
|
|
var oldCapture = Captured; |
|
|
|
|
|
var oldGestureRecognizer = CapturedGestureRecognizer; |
|
|
var oldSource = CaptureSource; |
|
|
var oldSource = CaptureSource; |
|
|
|
|
|
var oldEffectiveCapturer = EffectiveCapturer; |
|
|
|
|
|
|
|
|
// If a handler marks Implicit capture as handled, we still want them to have another chance if the element is captured explicitly.
|
|
|
// If a handler marks Implicit capture as handled, we still want them to have another chance if the element is captured explicitly.
|
|
|
if (oldCapture == control && oldSource == source) |
|
|
if (oldCapture == control && oldGestureRecognizer == gestureRecognizer && oldSource == source) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
var oldVisual = oldCapture as Visual; |
|
|
var oldVisual = oldCapture as Visual; |
|
|
@ -110,12 +115,17 @@ namespace Avalonia.Input |
|
|
|
|
|
|
|
|
if (oldVisual != null) |
|
|
if (oldVisual != null) |
|
|
oldVisual.DetachedFromVisualTree -= OnCaptureDetached; |
|
|
oldVisual.DetachedFromVisualTree -= OnCaptureDetached; |
|
|
|
|
|
|
|
|
|
|
|
if (oldGestureRecognizer != gestureRecognizer) |
|
|
|
|
|
oldGestureRecognizer?.PointerCaptureLostInternal(this); |
|
|
|
|
|
|
|
|
Captured = control; |
|
|
Captured = control; |
|
|
|
|
|
CapturedGestureRecognizer = gestureRecognizer; |
|
|
CaptureSource = source; |
|
|
CaptureSource = source; |
|
|
|
|
|
|
|
|
// However, we still want to notify the platform only if the captured element actually changed.
|
|
|
// However, we still want to notify the platform only if the captured element actually changed.
|
|
|
if (oldCapture != control && source != CaptureSource.Platform) |
|
|
if (oldEffectiveCapturer != EffectiveCapturer && source != CaptureSource.Platform) |
|
|
PlatformCapture(control); |
|
|
PlatformCapture(EffectiveCapturer); |
|
|
|
|
|
|
|
|
if (oldVisual != null) |
|
|
if (oldVisual != null) |
|
|
foreach (var notifyTarget in oldVisual.GetSelfAndVisualAncestors().OfType<IInputElement>()) |
|
|
foreach (var notifyTarget in oldVisual.GetSelfAndVisualAncestors().OfType<IInputElement>()) |
|
|
@ -128,9 +138,6 @@ namespace Avalonia.Input |
|
|
if (newVisual != null) |
|
|
if (newVisual != null) |
|
|
newVisual.DetachedFromVisualTree += OnCaptureDetached; |
|
|
newVisual.DetachedFromVisualTree += OnCaptureDetached; |
|
|
|
|
|
|
|
|
if (Captured != null) |
|
|
|
|
|
CaptureGestureRecognizer(null); |
|
|
|
|
|
|
|
|
|
|
|
if (Captured == null && CapturedGestureRecognizer == null) |
|
|
if (Captured == null && CapturedGestureRecognizer == null) |
|
|
{ |
|
|
{ |
|
|
IsGestureRecognitionSkipped = false; |
|
|
IsGestureRecognitionSkipped = false; |
|
|
@ -199,22 +206,7 @@ namespace Avalonia.Input |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
CaptureGestureRecognizerCore(gestureRecognizer); |
|
|
CaptureCore(null, gestureRecognizer, CaptureSource.Explicit); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void CaptureGestureRecognizerCore(GestureRecognizer? gestureRecognizer) |
|
|
|
|
|
{ |
|
|
|
|
|
if (CapturedGestureRecognizer != gestureRecognizer) |
|
|
|
|
|
{ |
|
|
|
|
|
CapturedGestureRecognizer?.PointerCaptureLostInternal(this); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CapturedGestureRecognizer = gestureRecognizer; |
|
|
|
|
|
|
|
|
|
|
|
if (gestureRecognizer != null) |
|
|
|
|
|
{ |
|
|
|
|
|
Capture(null); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|