I want to use the Table component to achieve the following functions
-
Right click the column header to pop up context menu
-
Right click each row to pop up context menu
I found that TableColumn and TableRow objects are not of type view. Setting contextMenu is not supported.
I can set the ContextMenu on the cell in the following ways, but it only works inside the cell, and clicking on the blank part does not take effect.
TableColumn("Given Name", value: \.givenName) { person in
Text(person.givenName)
.contextMenu(menuItems: {
Button {
} label: {
Text("New Order")
}
})
}
How to set independent context menus on rows and column headers?