SwiftUI Table with copy

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.

This may help I hope:

You need to make the view focusable: https://stackoverflow.com/questions/64241430/oncopycommand-on-macos-is-never-being-called-how-to-use-it

and

https://swiftui-lab.com/working-with-focus-on-swiftui-views/

I couldn't find a way to support record selections copying using onCopyCommand so I instead just removed the pasteboard group from the menu and implemented my own Copy command using CommandGroup(replacing: .pasteboard). I used FocusedValues to keep track of the selected records.

SwiftUI Table with copy
 
 
Q