I don't understand how to delete or move a item on macOS. What action should I need to do with the mouse to trigger onDelete
or onMove
events?
@State var wishList = ["Item 1", "Item 2", "Item3"]
var body: some View {
List {
ForEach(wishList, id:\.self) { item in
Button(action: {
}) {
Text(item)
}
}
.onDelete { offsets in
}
.onMove { source, target in
}
}
}
Move: Click and drag rows.
Delete: Swipe with (two fingers on trackpad or one finger on magic mouse), like the way you scroll horizontally.
Note that you should NOT click and drag the row like the way you swipe in iOS simulator. Just a simple mac horizontal scroll is enough.
These gestures won't work if you have an ordinary two-button mouse. You will need to make affordances in your UI for people with simpler mice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With