Skip to content

Commit

Permalink
fix(pointers): Pointers are not bubbling through list view on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Mar 6, 2023
1 parent 4e978a6 commit f111ba3
Showing 1 changed file with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public override void DeleteItems(NSIndexPath[] indexPaths)
try
{
base.DeleteItems(indexPaths);
}
}
#if NET6_0_OR_GREATER
catch (Exception e)
#else
Expand Down Expand Up @@ -778,6 +778,56 @@ public Thickness Padding
}

#region Touches
private UIElement _touchTarget;

/// <inheritdoc />
public override void TouchesBegan(NSSet touches, UIEvent evt)
{
base.TouchesBegan(touches, evt);

// We wait for the first touches to get the parent so we don't have to track Loaded/UnLoaded
// Like native dispatch on iOS, we do "implicit captures" the target.
if (this.GetParent() is UIElement parent)
{
// canBubbleNatively: true => We let native bubbling occur properly as it's never swallowed by system
// but blocking it would be breaking in lot of aspects
// (e.g. it would prevent all sub-sequent events for the given pointer).

_touchTarget = parent;
_touchTarget.TouchesBegan(touches, evt, canBubbleNatively: true);
}
}

/// <inheritdoc />
public override void TouchesMoved(NSSet touches, UIEvent evt)
{
base.TouchesMoved(touches, evt);

// canBubbleNatively: false => The system might silently swallow pointers after a few moves so we prefer to bubble in managed.
_touchTarget?.TouchesMoved(touches, evt, canBubbleNatively: false);
}

/// <inheritdoc />
public override void TouchesEnded(NSSet touches, UIEvent evt)
{
base.TouchesEnded(touches, evt);

// canBubbleNatively: false => system might silently swallow pointer after few moves so we prefer to bubble in managed.
_touchTarget?.TouchesEnded(touches, evt, canBubbleNatively: false);
_touchTarget = null;
}

/// <inheritdoc />
public override void TouchesCancelled(NSSet touches, UIEvent evt)
{
base.TouchesCancelled(touches, evt);

// canBubbleNatively: false => system might silently swallow pointer after few moves so we prefer to bubble in managed.
_touchTarget?.TouchesCancelled(touches, evt, canBubbleNatively: false);
_touchTarget = null;
}


private TouchesManager _touchesManager;

internal TouchesManager TouchesManager => _touchesManager ??= new NativeListViewBaseTouchesManager(this);
Expand Down

0 comments on commit f111ba3

Please sign in to comment.