On MacOS, I'm trying to create a List where I can click on items to select them, but I can also double click on them to do something else. As soon as I add tapGesture to my Text objects that I am using for items, their selection behavior breaks. I can no longer click on the actual text to select them, only in the empty space to the side of them. I understand the part of it that is explained here, but that doesn't solve my problem.
I tried to make something work with simultaneousGesture, as that's sort of what I'm trying to accomplish. But I need to retain the List's gesture functionality and add my own, not add two new ones.
Here is my code
struct ContentView: View {
private var animals = ["frog","toad","owl","piglet","bear","roo"]
@State private var selection = Set<String>()
var body: some View {
List(animals, id: \.self, selection: $selection, rowContent: { name in
Text(name).onTapGesture(count: 2) {
print("double clicked \(name)")
}
})
}
}
Any help would be appreciated. And please, if what I am trying to accomplish isn't clear, let me know. Thank you for reading.