在 SwiftUI 中从 macOS 上的列表中删除项目的鼠标手势是什么? [英] What mouse gesture to delete an item from a List on macOS in SwiftUI?

查看:25
本文介绍了在 SwiftUI 中从 macOS 上的列表中删除项目的鼠标手势是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白如何在 macOS 上删除或移动项目.我需要对鼠标执行什么操作来触发 onDeleteonMove 事件?

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
            }
        }
    }

推荐答案

- 移动:

点击并拖动行.

用两根手指轻扫,就像水平滚动一样.

Swipe with two fingers, like the way you scroll horizontally.

请注意,您不应该点击并拖动行,就像在 iOS 模拟器中滑动一样.一个简单的 mac 水平滚动就足够了.

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.

这篇关于在 SwiftUI 中从 macOS 上的列表中删除项目的鼠标手势是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆