"onTapGesture" interferes with segmented picker

struct ProblemSegmentTest: View {

    @State private var select = 0

    var body: some View {

        VStack {

            Picker("Test", selection: $select) {

                Text("A").tag(0)

                Text("B").tag(1)

                Text("C").tag(2)

            }

            .pickerStyle(SegmentedPickerStyle())

        }

        .onTapGesture {

            print("test")

        }

    }

}

I want to do sth when the picker is taped. However, when I apply ".onTapGesture" to the vstack, the picker's options can't be selected any more. Any help will be appreciated.

Can you explain what you mean by I want to do sth when the picker is taped? It may be preferable to describe what result you want on what sort of user action/event.

the picker options can be selected, you have to slide your finger or mouse, not just tap on it.

@OOPer By default, when the picker is tapped, the corresponding option will be selected. In addition to this,I also need to execute some other codes as long as any area within picker is tapped, no matter which option is selected. In other words, I need to know which option user taps, at the mean time I also need to know user is tapping within the picker scope.

@workingdogintokyo That's true. And long pressing on the option will also work. However, I want users can just click on it to select options. Otherwise, it seems to have a little bug, from the users' perspective.

I also have this issue. Adding any sort of tap gesture to the view interferes with the picker's ability to change selections when tapped. This happens even if the tap gesture has nothing to do with the picker. In my case, it occurs on a view that has a picker and a custom text field, with a tap gesture that hides the keyboard placed on the main body of the view.

(ETA: Sorry, meant to put this in the comments.)

"onTapGesture" interferes with segmented picker
 
 
Q