Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Cannot prevent copy/Select option in a webView Custom renderer

$
0
0

I'm trying to prevent Copy/Select in a web view using a custom render (iOS). I am using the CanPerform() function , but it never asks about Copy or select. The code I am using in the custom renderer is:

public override bool CanPerform(ObjCRuntime.Selector action, NSObject withSender)
    {
      if (action.Name == "cut:" ||
          action.Name == "select:" ||
          action.Name == "paste:" ||
          action.Name == "copy:" ||
          action.Name == "selectAll:")
      {
        Console.WriteLine("     DisAllow   [{0}]", action.Name);
        return false;
      }
      else
      {
        Console.WriteLine("        Allow   [{0}]", action.Name);
        return base.CanPerform(action, withSender);
      }
    }

WriteLine results are:

 DisAllow  [cut:]
 DisAllow  [select:]
 DisAllow  [paste:]
    Allow  [delete:]
    Allow  [_promptForReplace:]
    Allow  [_transliterateChinese:]
    Allow  [_showTextStyleOptions:]
    Allow  [_lookup:]
    Allow  [_addShortcut:]
    Allow  [_accessibilitySpeak:]
    Allow  [_accessibilitySpeakLanguageSelection:]
    Allow  [_accessibilityPauseSpeaking:]
    Allow  [makeTextWritingDirectionRightToLeft:]
    Allow  [makeTextWritingDirectionLeftToRight:]

The Cut, Select and Paste options are correctly removed. Unfortunately, Copy and SelectAll still show on the popup. As you can see, the "Copy" and "Select" do not show up on the CanPerform Event.

Why are Copy and SelectAll not showing on the Event and how can I get them to show up so I can eliminate them.

Thanks.


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>