Original question here: https://stackoverflow.com/q/59280263/3939277
I'm writing a simple Mines app to help me get to know SwiftUI. As such, I want primary click (usually LMB) to "dig" (reveal whether there's a mine there), and secondary click (usually RMB or 2-finger click) to place a flag.
I have the digging working! But I can't figure out how to place a flag, because I can't figure out how to detect a secondary click.
BoardSquareView(
style: self.style(for: square),
model: square
)
.gesture(TapGesture().modifiers(.control).onEnded(self.handleUserDidAltTap(square)))
.gesture(TapGesture().onEnded(self.handleUserDidTap(square)))
As I implied earlier, the function returned by `handleUserDidTap` is called properly on click, but the one returned by `handleUserDidAltTap` is only called when I hold down the Control key. That makes sense because that's what the code says... but I don't see any API which could make it register secondary clicks, so I don't know what else to do.
I also tried this, but the behavior seemed identical:
BoardSquareView(
style: self.style(for: square),
model: square
)
.gesture(TapGesture().modifiers(.control).onEnded(self.handleUserDidAltTap(square)))
.onTapGesture(self.handleUserDidTap(square))