iOS Question How to disable text selection of TextField

susu

Well-Known Member
Licensed User
Longtime 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

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime 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?
 
Upvote 0

JanPRO

Well-Known Member
Licensed User
Longtime User
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?
But the TextField should be still editable?
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0
Top