Apple Pencil drag reset

Heya, I’m not a developer but a user but I noticed a lot of AUv3 are having a similar issue with Apple Pencil.

Any knobs or faders with intractable UI elements will respond to the pencil until it is lifted and the value is reset.

I am running on iPad mini A17 with an Apple Pencil Pro. Someone else has reproduced the issue on a new iPad Pro.

FWIW (this may be useful to the JUCE team), I’ve found that MouseInputSource ( JUCE: juce::MouseInputSource Class Reference ) is just totally broken in testing. I see it always report the same thing on iOS no matter what. So maybe something changed on iOS recently that broke the recognition of Pencils and mice on iOS, which could be affecting standard UI elements like Sliders.

Hi there. Are you saying that isMouse(), isTouch(), isPen(), canHover(), hasMouseWheel(), etc. always report the same values, no matter what is connected? Could you please say more about your devices, iOS versions and JUCE version?

I’m going off of memory but yes, that’s basically right. I tested with an iPad running 18.5 and JUCE 8 (I’m typically up to date, this was probably 8.0.11 or .12). I don’t have a Pencil but got reports of regressions from users with a Pencil or mouse and looked into it, so I was comparing touch screen and mouse behavior. IIRC, I saw on iOS that isMouse was always true, in spite of whatever device or input I was using.

Furthermore, I found that when using a mouse or Pencil on iOS, there would be a simultaneous mouseDrag event generated every time a mouseDown occurred, which messed up a ton of my Viewport logic. This was how the issue came to my attention. Typically for iOS I disable Viewport scrolling when someone is interacting with a button, slider, etc. inside of the Viewport, and I started getting user reports that my menus were all unresponsive when using a mouse/Pencil. I worked around this by checking all mouseDrag events and ignoring if they were less than ~8px from the mouseDown location, which I’d probably recommend for everyone anyway (slash I’d maybe even argue there should be some configurable threshold in JUCE as well)

I’ve found that on mobile devices mouseDrag events are continuously called when touching the screen whereas on desktop devices the mouse is more “stable” so they only happen when actively moving the mouse.

Do you also get coninuous mouseDrag events when using a touch input on iOS? And do you get just one mouseDrag event along with the mouseDown when using a mouse or pencil, while you expected none?

Sounds familiar! That can be quite tricky. See the first point in this feature request: FR: Viewport improvements

1 Like

It would be nice to get this fixed, as it affects all our products on iPad. (And many, many other companies that I can tell; it’s an easy test whether a product is JUCE or not.) I get fairly consistent complaints from Pencil users. The fix is simple. Line 2168 of juce_UIViewComponentPeer_ios.mm should be changed from

ModifierKeys::getCurrentModifiers(),

to

ModifierKeys::getCurrentModifiers().withoutMouseButtons(),

JUCE doesn’t check UITouch.type at all and the UIHoverGestureRecognizer fires for Apple Pencil hover on iOS 16+. When the pencil lifts, hover events fire that can carry stale button modifiers, causing the Slider to process spurious drag/up events. This small edit prevents Apple Pencil hover-to-touch transitions from generating events that interfere with an active drag.

7 Likes

Yes, it affects all our products too, please fix this JUCE, thank you!

1 Like

We’re affected as well, so another bump to fix this. Thanks in advance!

1 Like

We’ve pushed some improvements in this area:

Please try out the latest changes on the develop branch, and let us know if you’re still seeing problems with pointing-device input.

1 Like