I have selectable Text, so when the user right clicks the text they see an edit menu with various options. I'd like to add some custom options to this menu but I'm not sure how to do this. If I can't add custom options, I'm also ok with completely replacing the menu altogether with my own custom menu.
Here is some sample code:
struct TestView: View {
var body: some View {
Text("Hello")
.textSelection(.enabled)
}
}
Here are some things I've tried:
- adding a context menu with
.contextMenu(). But right clicking will still only show the edit menu and not the context menu. - I've also tried disabling overriding right click behavior to stop the native edit menu from showing up (i.e. Override right click in SwiftUI), but that doesn't work.