3

I would like to remove the ability to select the text in a TouchScreenKeyboard text field (IOS), or disable the ability to lookup the text (see attached picture). I've seen some answer here on Stackoverflow talking about it but i'ts not for Unity.

Should i create a native plugin or is there an easier way to do this?

Some sources on similar issues:

How to remove lookup & share from textview in Swift 3

How to disable UITextview selection text, copy/paste UIMenuController but still have hyperlinks working [Not duplicate]

How to disable copy paste option from UITextField programmatically

Thanks!

enter image description here

EDIT:

A solution which is not optimal is to edit the Xcode project that is generated by Unity when building:

Open the Xcode project and add these two files NonLookupField.h and NonLookupField.m in Classes --> UI

NonLookupField.h

#import <UIKit/UIKit.h>


@interface NonLookupField : UITextField
@end

NonLookupField.m

#import <Foundation/Foundation.h>
#import "NonLookupField.h"

@implementation NonLookupField

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
    if (action == @selector(copy:) ||
        action == @selector(selectAll:)) {
        return true;
    }

    return false;
}

@end

Replace all instances of UITextField with the newly created NonLookupField in keyboard.mm

fleppe
  • 53
  • 1
  • 8
  • Is there a specific reason you want this? This is usually a feature devs try hard to implement. – Lou Garczynski Jan 24 '20 at 03:28
  • @LouisGarczynski Apple doesn't allow outgoing links in apps that are categorised in the kids section. The lookup functionality counts as outgoing link by apple reviewers. – fleppe Jan 27 '20 at 17:04
  • Have you tried modifying the built xcode project to add the correct canPerformAction implementation ? It's a hack, but it might work temporarily. – Lou Garczynski Jan 28 '20 at 20:44
  • 1
    Yeah, actually i managed to fix it overriding the UITextField with a custom @implementation. But it's not pretty! – fleppe Jan 29 '20 at 21:34
  • Considering your post is the only one on the subject, would you mind sharing your solution? – Lou Garczynski Jan 31 '20 at 03:09
  • 1
    @LouisGarczynski i edited the question with that solution. – fleppe Jan 31 '20 at 19:51
  • Ideally you should answer it using the answer box, that way people can vote on it. That still works for me though, thanks for your addition. – Lou Garczynski Feb 02 '20 at 09:44

0 Answers0