List-like Selection for custom containers

The new contextMenu(forSelectionType:menu:) implementation is pretty nifty, but as far as I can tell the only views that support it are List and Table.

I was wondering if it's possible to support this new behavior with a custom container, and if so -- how?

I am not sure I understand your question correctly, contextMenu could be added to any custom view

struct ContentView: View {
    var body: some View {
        Text("Hello, world!")
            .padding()
            .contextMenu {
                Button("aaa") {}
            }
    }
}

From the documentation for this modifier:

Use an item-based context menu with a container that supports selection, such as a List or Table.

I don't think it is possible as there is no current API for selection in custom views as this is what the context menu is looking for.

List-like Selection for custom containers
 
 
Q