diff --git a/source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Android/SKTouchHandler.cs b/source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Android/SKTouchHandler.cs index fcfd4861b8..d3da69e7fe 100644 --- a/source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Android/SKTouchHandler.cs +++ b/source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Android/SKTouchHandler.cs @@ -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; } @@ -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; } @@ -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; } @@ -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; } } diff --git a/source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Shared/SKTouchEventArgs.cs b/source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Shared/SKTouchEventArgs.cs index dc10964f54..0a1d0323bd 100644 --- a/source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Shared/SKTouchEventArgs.cs +++ b/source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Shared/SKTouchEventArgs.cs @@ -28,6 +28,12 @@ public SKTouchEventArgs(long id, SKTouchAction type, SKMouseButton mouseButton, public bool Handled { get; set; } + /// + /// Disallow Touch intercept hook for Andriod systems + /// + /// + public bool RequestDisallowIntercept { get; set; } + public long Id { get; private set; } public SKTouchAction ActionType { get; private set; } @@ -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}}}"; } }