0
votes
struct ContentView: View {

    @State var text = ""
    var body: some View {
        Form {
            Button(action: {
                print("Button pressed")
            }) {
                Text("Button")
            }
        }.simultaneousGesture(TapGesture().onEnded( { print("tap") }))
    }
}

I need both Button' action and tap gesture on Form to be caught, but only print("tap") is executed. For a VStack works fine, but it seems the Form is a little bit special. Any idea ?

1

1 Answers

1
votes

if you do it like this, you will get the button tap (but also the form tap). I don't know if this helps you.

@State var text = ""
var body: some View {
    Form {
        Button(action: {

        }) {
            Text("Button")
        }.onTapGesture {
            print("button")
        }
    }.onTapGesture {
        print("form")
    }    }
}