0 Replies
      Latest reply on Nov 5, 2019 6:02 PM by RickMaddy
      RickMaddy Level 1 Level 1 (0 points)

        In my iPad app running under macOS Catalyst I would like to modify the context menu that appears when you right-click on a UITextViiew but I can't figure out how.

         

        I have overridden the buildMenuWithBulder:/buildMenu(with:) method from UIResponder in my view controller and app delegate but none are called when right-clicking on a UITextView.

         

        I have been able to disable a couple of the menu options by subclassing UITextView and overriding the canPerformAction:withSender:/canPerformAction(_:withSender:) and targetForAction:withSender:/target(_:withSender:) methods but I can't remove/disable most of the menu.

         

        I also overrode the validateCommand:/validate(_:) method in my UITextView subclass and that was only called for a small subset of the menus I wish to remove/disable.

         

        The Menus sample app only shows how to modify the app's main menu and how to add a context menu to a view controller but there is no info on how to modify the context menu of a control such as UITextView.

         

        Does anyone know how to do this?

         

        Specifically I want to remove the Show Fonts and Show Colors menus under Font and I wish to remove the whole Substitutions menu. The allowsEditingTextAttributes property of the text view is enabled which is what makes the Font portion of the menu appear. I want to keep the Bold/Italic/Underline toggles.