How to fire only one .gesture when there is shift pressed

Viewed 27

I have a view that will have two kinds of tap gestrures attached to it. Something like

view
.gesture(TapGesture().onEnded {...}) // <-- Don't fire this when shift is pressed
.simultaneousGesture(TapGesture().modifiers(.shift).onEnded {....})

How I prevent the first gesture to be fired when shift is pressed. Under all circumstances I want only one gesture to be fired.

applying both gestures on view like .gesture does not work The second one is not fired at all, under any circumstance.

1 Answers

Try to make second one with higher priority, like

view
.gesture(TapGesture().onEnded {...})
.highPriorityGesture(TapGesture().modifiers(.shift).onEnded {....})
Related