6

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.