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

    Hi,

    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:
    Code:
    Dim no As NativeObject = YourTextView
    no.SetField(
    "selectable"false)
     
    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:
    Code:
    Dim no As NativeObject = addressEntryBox
        no.SetField(
    "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:
    Code:
    Sub addressEntryBox_TextChanged (Old As String, New As String)
        
    If New.Length > Old.Length + 2 Then
            
    'paste must have occurred
     
Loading...
  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