iOS Question How to disable text selection of TextField

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?
 

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:
B4X:
Dim no As NativeObject = addressEntryBox
    no.SetField("selectable", False)        'prevent copy/paste
 

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?
 

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:
B4X:
Sub addressEntryBox_TextChanged (Old As String, New As String)
    If New.Length > Old.Length + 2 Then
        'paste must have occurred
 
Top