In macOS Ventura, a new modifier, contextMenu(forSelectionType:menu:primaryAction:), was introduced to allow for a primary action to executed in selection-based containers along with the standard context menu.
List(selection: $selectedItem) {
...
}
.contextMenu(forSelectionType: String.self, menu: { _ in }) {
// double tap action
}
Single tap selection still works as well as the double tap action (specific to macOS).
There was a contextAction(forSelectionType:action:) modifier originally which was removed and merged with the context menu one. I'm not sure why but it does mean you have to pass in an empty closure to the menu parameter if you want the same functionality.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: