dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.26k stars 1.76k forks source link

PointerGestureRecognizer does not support multi touch on iOS - no individual touch / pointer information available #23041

Open ayaphi opened 5 months ago

ayaphi commented 5 months ago

Using PointerGestureRecognizer on a GraphicsView and its OnPointer-Events I cannot handle multi-touch input on iOS (tested with an iPad).

Receiving information from a single touch or an Apple pen works okay - although the interval between OnPointerMove events, and hence the distance between the points (X & Y coordinate offsets) with each successive event, is getting quite large with fast movements of the pointer (touch & pen on the iPad and mouse on the iOS simulator) and they are surprisingly roughly twice as large as on Windows (with a mouse).

Or in other words : the pointer position tracking on Windows is way more accurate or has a higher resolution than on iOS.

But what's crucial, even looking at the UIGestureRecognizer platform pointer EventArgs for iOS and Mac Catalyst, I cannot find a way to get hold of the individual touch / pointer information.

Looking at platform pointer EventArgs for Windows, PointerRoutedEventArgs, I see that I can get a PointerId, which makes it possible to distinguish and handle multi touch inputs - tracking the position of each touch individually (its not about gestures, I need the raw points).

But how to achieve this on iOS? I saw a custom GestureRecognizerView implementation for iOS that drops down into the platform code using an UIView. But sadly that library does not work any work - I experience a crash at app startup.

But nevertheless this approach of a transparent UIView on top of the .NET MAUI views in the page may be a solution - or is there another way to get individual multi-touch information inside a .NET MAUI page or view.

mattleibow commented 8 hours ago

Can you use the platform args? https://learn.microsoft.com/dotnet/api/microsoft.maui.controls.pointereventargs.platformargs