Skip to content

Commit

Permalink
fix: make sur eto not filter ou event for implicit captures
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Apr 13, 2020
1 parent fcb7178 commit 425cf4b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Uno.UI/UI/Xaml/UIElement.PointerCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ private PointerCapture(Pointer pointer)
/// </summary>
public long MostRecentDispatchedEventFrameId { get; private set; }

/// <summary>
/// Determines if this capture was made only for implicit kind
/// (So we should not use it to filter out some event on other controls)
/// </summary>
public bool IsImplicitOnly { get; private set; } = true;

public IEnumerable<PointerCaptureTarget> Targets => _targets.Values;

public bool IsTarget(UIElement element, PointerCaptureKind kinds)
Expand Down Expand Up @@ -132,6 +138,7 @@ public bool TryAddTarget(UIElement element, PointerCaptureKind kind, PointerRout
// If we added an explicit capture, we update the _localExplicitCaptures of the target element
if (kind == PointerCaptureKind.Explicit)
{
IsImplicitOnly = false;
element._localExplicitCaptures.Add(Pointer);
}

Expand Down Expand Up @@ -190,20 +197,22 @@ private void RemoveCore(PointerCaptureTarget target, PointerCaptureKind kinds)
}

// If we remove an explicit capture, we update the _localExplicitCaptures of the target element
if (kinds.HasFlag(PointerCaptureKind.Explicit)
if (kinds.HasFlag(PointerCaptureKind.Explicit)
&& target.Kind.HasFlag(PointerCaptureKind.Explicit))
{
target.Element._localExplicitCaptures.Remove(Pointer);
}

target.Kind &= ~kinds;

// The element is no longer listing for event, remove it.
// The element is no longer listening for events, remove it.
if (target.Kind == PointerCaptureKind.None)
{
_targets.Remove(target.Element);
}

IsImplicitOnly = _targets.None(t => t.Value.Kind.HasFlag(PointerCaptureKind.Explicit));

// Validate / update the state of this capture
EnsureEffectiveCaptureState();
}
Expand Down Expand Up @@ -234,6 +243,12 @@ public bool ValidateAndUpdate(UIElement element, PointerRoutedEventArgs args, bo

return true;
}
else if (IsImplicitOnly)
{
// If the capture is implicit, we should not filter out events for child elements.

return true;
}
else
{
// We should dispatch the event only if the control which has captured the pointer has already dispatched the event
Expand Down

0 comments on commit 425cf4b

Please sign in to comment.