I am using SwiftUI for Mac OS and so far I have not been able to implement tap gestures. I want to double click on a row of the Table and have that perform an action using the contents of that row. Does anyone know if it is even possible to use the .onTapGesture or anything similar to a SwiftUI Table? Any help is appreciated! Thanks!
is it possible to use gestures with SwiftUI Table?
use .onTapGesture(count:, perform:)
Example: SwiftUI Table
Table(selection: $selection, sortOrder: $sortOrder) {
TableColumn("Variety", value: \.variety)
TableColumn("Days to Maturity", value: \.daysToMaturity) { plant in
Text(plant.daysToMaturity.formatted())
.onTapGesture(count: 2) {
tapped.toggle()
}.alert("Close", isPresented: $tapped) {
Button {
tapped.toggle()
} label: {
Text("Bye")
}
}
}
Hey @MobileTen, Thanks for responding! I appreciate the help. I should have made myself clearer though in that I want to be able to double click anywhere in the row and not just the text in a certain column. Or at least anywhere in the cell containing the text. Any other ideas on how I could possible make this work? Thanks again!