I've implemented a macOS app that displays a table of records in a document using SwiftUI. However, I want to allow the user to copy selected records. I've tried adding onCopyCommand
, but I'm not seeing Edit -> Copy
enabled.
HSplitView {
Table(records, selection: $selectedRecordIDs) {
TableColumn("Timestamp", value: \.timestamp.description)
TableColumn("Message", value: \.message)
.width(ideal: columnWeight.message * geometry.size.width)
}
.onCopyCommand {
[NSItemProvider(item: "Hello, World!" as NSString, typeIdentifier: UTType.plainText.identifier)]
}
How to enabled Copy
?
Thanks.