Missing two fingers UITouch events

I'm working on a pan+zoom user interface and the touch events I get through Catalyst are inconsistent with those received on iPad/iPhone.

Two fingers generate the expected events for pinch and zoom, but if the fingers move parallel, touchMoved events that don't actually move get generated. My expectation is that the events get eaten by the system generating scroll events instead, but there doesn't seem to be any way to get those.


Has anybody encountered this problem ? Right now people can still pan through click+drag, but it really doesn't feel comfortable. Any suggestion ?

Post not yet marked as solved Up vote post of jmuffat Down vote post of jmuffat
1.4k views

Replies

Check out the new "UIApplicationSupportsIndirectInputEvents" mode discussed in WWDC 2020's "Handle trackpad and mouse input" video: https://developer.apple.com/wwdc20/10094
Hi  jmuffat,

As Frameworks Engineer has stated, you may want to look at UIApplicationSupportsIndirectInputEvents if you haven't done so already.

By default, UIPinchGestureRecognizer and UIRotationGestureRecognizer use gesture simulating touches that start a fixed distance apart. These touches are then modified to simulate movement on the trackpad. Because of that, those touches can activate other gestures, which may be what is happening here.

If you adopt UIApplicationSupportsIndirectInputEvents UIPinchGestureRecognizer and UIRotationGestureRecognizer will be driven by a new event of type UIEvent.EventType.transform with trackpad input, which will be much more precise.


My expectation is that the events get eaten by the system generating scroll events instead, but there doesn't seem to be any way to get those.

Scroll input is handled by UIPanGestureRecognizer by updating its allowedScrollTypesMask property. When you do that, you'll enable scroll input for your pan, and it will be driven by the event of type UIEvent.EventType.scroll. If there are scroll events involved, it should be seeing those at this point.

Note that UIEvent.EventType.transform and UIEvent.EventType.scroll are *not* touch-based, so you won't get touches for either of these events. Some gotcha's are mentioned in the documentation Frameworks Engineer posted above related to this fact.

If you haven't already, you should check out this video on handling trackpad and mouse input, as it applies to both iPad and Catalyst:
https://developer.apple.com/videos/play/wwdc2020/10094/

Hope that helps.


Oh, and there's text documentation on UIApplicationSupportsIndirectInputEvents as well:

https://developer.apple.com/documentation/bundleresources/information_property_list/uiapplicationsupportsindirectinputevents