DragGesture freezes when a second finger is added

I have a DragGesture set up like this:

Code Block Swift
let drag = DragGesture(minimumDistance: 0)
.onChanged { _ in
    print("changed")
}
.onEnded { _ in
print("ended")
}
content.gesture(drag) /// content is the View that I'm adding the gesture to

This works fine with just one finger. However, once I press down with a second finger, .onEnded is never called.

Is there a way to allow only one finger for the gesture?

I've seen similar issues here and here, but they didn't work for me.

Replies

Is onChanged called ?

There does not seem to be a native multiple fingers handling in SwiftUI for DragGesture.

You could probably build upon TapGesture, as described here.
https://stackoverflow.com/questions/61566929/swiftui-multitouch-gesture-multiple-gestures
Hey @Claude31, thanks for your help! It's now working if I do

Code Block swift
@GestureState private var isPressed = false
...
let drag = DragGesture(minimumDistance: 0)
.updating($isPressed) { (value, gestureState, transaction) in
gestureState = true
}
return content
.gesture(drag)
.onChange(of: isPressed, perform: { (pressed) in
if pressed {
print("changed")
} else {
print("ended")
}
})

as suggested by someone else and also Apple. Here's the feedback Apple sent:

Thank you for filing this feedback report. We reviewed your report and determined the behavior you experienced is currently functioning as intended.
The gesture is cancelled in this case not ended (two fingers can't match a one-finger drag). You can use GestureState to handle the cancellation.
You can close this feedback by clicking on the "Close Feedback" link. Thank you.