Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow intercept of touch event by adding option in SKTouchEventArgs #1096

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ private void OnTouch(object sender, View.TouchEventArgs e)
var args = new SKTouchEventArgs(id, SKTouchAction.Pressed, coords, true);
onTouchAction(args);
e.Handled = args.Handled;

if (args.RequestDisallowIntercept && (sender is View view))
view.Parent?.RequestDisallowInterceptTouchEvent(true);

break;
}

Expand All @@ -69,6 +73,10 @@ private void OnTouch(object sender, View.TouchEventArgs e)
var args = new SKTouchEventArgs(id, SKTouchAction.Moved, coords, true);
onTouchAction(args);
e.Handled = e.Handled || args.Handled;

if (args.RequestDisallowIntercept && (sender is View view))
view.Parent?.RequestDisallowInterceptTouchEvent(true);

}
break;
}
Expand All @@ -79,6 +87,10 @@ private void OnTouch(object sender, View.TouchEventArgs e)
var args = new SKTouchEventArgs(id, SKTouchAction.Released, coords, false);
onTouchAction(args);
e.Handled = args.Handled;

if (sender is View view)
view.Parent?.RequestDisallowInterceptTouchEvent(false);

break;
}

Expand All @@ -87,6 +99,10 @@ private void OnTouch(object sender, View.TouchEventArgs e)
var args = new SKTouchEventArgs(id, SKTouchAction.Cancelled, coords, false);
onTouchAction(args);
e.Handled = args.Handled;

if (sender is View view)
view.Parent?.RequestDisallowInterceptTouchEvent(false);

break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public SKTouchEventArgs(long id, SKTouchAction type, SKMouseButton mouseButton,

public bool Handled { get; set; }

/// <summary>
/// Disallow Touch intercept hook for Andriod systems
///
/// </summary>
public bool RequestDisallowIntercept { get; set; }

public long Id { get; private set; }

public SKTouchAction ActionType { get; private set; }
Expand All @@ -44,7 +50,7 @@ public SKTouchEventArgs(long id, SKTouchAction type, SKMouseButton mouseButton,

public override string ToString()
{
return $"{{ActionType={ActionType}, DeviceType={DeviceType}, Handled={Handled}, Id={Id}, InContact={InContact}, Location={Location}, MouseButton={MouseButton}, WheelDelta={WheelDelta}}}";
return $"{{ActionType={ActionType}, DeviceType={DeviceType}, Handled={Handled},RequestDisallowIntercept={RequestDisallowIntercept}, Id={Id}, InContact={InContact}, Location={Location}, MouseButton={MouseButton}, WheelDelta={WheelDelta}}}";
}
}

Expand Down