I tested on simulator in playground on Mojave
struct ContentView: View
{
let data = [
"Test 1","Test 2","Test 3","Test 4","Test 5",
"Test 6","Test 7","Test 8","Test 9","Test 10",
"Test 11","Test 12","Test 13","Test 14","Test 15",
"Test 16","Test 17","Test 18","Test 19","Test 20"
]
var body: some View
{
List
{
ForEach(data, id:\.self)
{
item in
Text(item).onLongPressGesture{ print(item)}
}
}
}
}
I works OK:
- I get the print with longPress on item name
Test 6
Test 10
- I can scroll the list later, by dragging on cell, but not taping on the label itself (but on the empty part of cell).
adding onTapGesture before onLongPressGesture makes it work all wherever you drag
struct ContentView: View
{
let data = [
"Test 1","Test 2","Test 3","Test 4","Test 5",
"Test 6","Test 7","Test 8","Test 9","Test 10",
"Test 11","Test 12","Test 13","Test 14","Test 15",
"Test 16","Test 17","Test 18","Test 19","Test 20"
]
var body: some View
{
List
{
ForEach(data, id:\.self)
{
item in
Text(item)
.onTapGesture { }
.onLongPressGesture{ print("longPressed", item)}
}
}
}
}