From 3e4e8db670d56f7e72d4bd6979b8dcb57b2e8e2b Mon Sep 17 00:00:00 2001 From: Jack Phelan Date: Fri, 29 Nov 2024 14:56:46 -0500 Subject: [PATCH] Add more details to apple touch events --- .../Platform/Apple/SKTouchHandler.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Core/Platform/Apple/SKTouchHandler.cs b/source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Core/Platform/Apple/SKTouchHandler.cs index 3b88e3ef24..9cd0b2695d 100644 --- a/source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Core/Platform/Apple/SKTouchHandler.cs +++ b/source/SkiaSharp.Views.Maui/SkiaSharp.Views.Maui.Core/Platform/Apple/SKTouchHandler.cs @@ -104,7 +104,18 @@ private bool FireEvent(SKTouchAction actionType, UITouch touch, bool inContact) var cgPoint = touch.LocationInView(View); var point = scalePixels(cgPoint.X, cgPoint.Y); - var args = new SKTouchEventArgs(id, actionType, point, inContact); + SKMouseButton mouse = SKMouseButton.Left; + SKTouchDeviceType device = touch.Type switch + { + UITouchType.IndirectPointer => SKTouchDeviceType.Mouse, + UITouchType.Indirect => SKTouchDeviceType.Mouse, + UITouchType.Stylus => SKTouchDeviceType.Pen, + UITouchType.Direct => SKTouchDeviceType.Touch, + _ => SKTouchDeviceType.Touch + + }; + + var args = new SKTouchEventArgs(id, actionType, mouse, device, point, inContact, 0); onTouchAction(args); return args.Handled; }