我已经包装了 NSPathControl 以在我的 Mac OS SwiftUI 应用程序中使用,但我无法弄清楚如何使路径的大小更小,或者如何让单个路径在单击时在 Finder 中打开位置。
这是包装:
struct PathView: NSViewRepresentable {
typealias pathViewNSView = NSPathControl
var configuration = { (view: pathViewNSView) in }
func makeNSView(context: NSViewRepresentableContext<PathView>) -> NSPathControl {
pathViewNSView()
}
func updateNSView(_ nsView: NSPathControl, context: NSViewRepresentableContext<PathView>) {
configuration(nsView)
}
}
我使用这样的视图:
PathView { view in
view.url = URL(fileURLWithPath: "/Volumes/Users/myfolder", isDirectory: true)
}
我知道使用 NSWorkspace.shared.selectFile 在 Finder 中打开路径,但不确定如何使用包装的 NSPathControl 执行此操作。