iOS Question How to disable text selection of TextField

Discussion in 'iOS Questions' started by susu, Mar 17, 2015.

  1. susu

    susu Well-Known Member Licensed User


    I use TextField to show multi line text. I set Editable = False but when I tap and hold the text, there's popup to copy/cut text. How to disable it?
  2. Erel

    Erel Administrator Staff Member Licensed User

    Try this:
    Dim no As NativeObject = YourTextView
    omidaghakhani1368 and susu like this.
  3. Arf

    Arf Active Member Licensed User

    I am trying to do this too, I get an error though.

    "[<UITextField 0x14ec8b30> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key selectable."

    My code:
    Dim no As NativeObject = addressEntryBox
    "selectable"False)        'prevent copy/paste
  4. JanPRO

    JanPRO Well-Known Member Licensed User

    It only works for a TextView ...
    Arf likes this.
  5. Arf

    Arf Active Member Licensed User

    Oh dammit, thread title said TextField.

    Is there anything I can do to prevent copy/paste in a TextField, or any event I can use to detect a copy or paste?
  6. JanPRO

    JanPRO Well-Known Member Licensed User

    But the TextField should be still editable?
  7. Arf

    Arf Active Member Licensed User

    Yes, I want the user to be able to type text, but not copy the text or paste text in.

    I've managed to detect a paste event like this, seems to work OK:
    Sub addressEntryBox_TextChanged (Old As String, New As String)
    If New.Length > Old.Length + 2 Then
    'paste must have occurred
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice