Post

Replies

Boosts

Views

Activity

Right-Click, UIContextMenuInteraction, & UITouch.Type.indirectPointer in iOS 13.4
HelloI'm working to enable proper trackpad support for iOS 13.4+, with the new iPad Magic Keyboard. This has been a relatively straightfoward process, but I've run into an issue around Right-Click support.TLDR: I'd like to be able to tell if a UIContextMenuInteraction was triggered via a right-click from a trackpad (indirect pointer), or from a long-press from a single-tap figure gesture (direct) but that seems impossible given that you cannot navigate from the Interaction to the TouchType that invoked it.---AFAIK, "right-click" support in iPadOS is enabled via a UIContextMenuInteraction. The one required delegate method returns a nullable UIContextMenuConfiguration. Our app does not support UIContextMenus at this time, but we'd like to use right-clicking, so we run custom code in the delegate method prior to returning nil for the confiiguration. This all works as expected.The problem comes from the fact that now we "support" UIContextMenus. The interaction is added to our view, which also has a custom long-press gesture recognizer. This long press is triiggered at the same time as the UIContextMenuInteraction, causing conflicting behaviors as both gestures activate.Unfortunately, it seems impossible to work backward from a UIContextMenuInteraction to the touchType that invoked it. You can retrieve the view property, but you can't work backwards from there to the active touch. Overriding the touchesBegan/etc methods allows for touchType detection, but the timing throws things off: the UIContextMenuInteractioniDelegate method triggers before any of the touch handlers, so I can't even track activeTouches independently.Additionially, since the gestures that track UIContextMenuInteractioni & Trackpad support etc are private, I can't subclass them to properly track touchType either.---Is there any way to differentiiate UIContextMenuIInteractions triggered from a trackpad right-click, vs one from direct long press?Thanks,Nick
2
0
845
Jun ’20