mono / SkiaSharp

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.52k stars 540 forks source link

[FEATURE][QUESTION] Support for macOS Multitouch Events on Xamarin.Forms #826

Open nor0x opened 5 years ago

nor0x commented 5 years ago

Is your feature request related to a problem? Please describe. In #309 touch events where added to SkiaSharp. In the conversation of the PR it says that multitouch is fully supported that it's correct for iOS and Android, butt not macOS as it seems. I tried a pinch and two-finger pan gesture with the trackpad but OnTouch(SKTouchEventArgs e) doesn't get called.

Describe the solution you'd like a great solution would be that trackpad gestures are handled the same way as touch gestures on a mobile platform (iOS / Android). In the file source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Mac/SKTouchHandler.cs i saw that SKTouchHandler derives from NSGestureRecognizer so maybe we could add override void Magnify(NSEvent magnifyEvent) to support the pinch gestures. For two-finger panning i think maybe override void ScrollWheel(NSEvent theEvent) is a good starting point.

Describe alternatives you've considered An alternative for pinch gestures would be to use a Xamarin.Forms PinchGestureRecognizer but my current application also supports Android and as mentioned in #309 Xamarin.Forms GestureRecognizers won't work in that case. So I would have to do are Runtime checks like:

if(Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.macOS)
{
     var pinch = new PinchGestureRecognizer();
     pinch.PinchUpdated += OnPinch;
     this.GestureRecognizers.Add(pinch);
}

Is this something that's planned for future releases? thanks

mattleibow commented 4 years ago

Tentatively moving this to the next version of SkiaSharp.