I have a textbox with a content which I want to protect from accidental changes. For this I am using a text box with IgnoreKey.
However I would also like the user to be able to copy parts from that text. Unfortunately the IgnoreKey also makes the textbox ignore ctrl-C (although you can mark text with shift-arrow). Is there any easy solution to this that I have overlooked?
You can do it by creating your own copy and paste buttons and using the selstart and sellength property. Example attached
B4X:
Sub Globals
'Declare the global variables here.
Dim CopyText
End Sub
Sub App_Start
Form1.Show
End Sub
Sub TextBox1_KeyPress (key)
textbox1.IgnoreKey
End Sub
Sub btnCopy_Click
copyText=SubString(textbox1.text,textbox1.SelectionStart,textbox1.SelectionLength)
End Sub
Sub btnPaste_Click
textbox2.Text=copytext
End Sub
Thank you Leginus,
I can see that that is also a way of doing it, it's just that I'm a firm believer of standardisation and when you have learned that Ctrl-C copies the text in almost all applications it is very frustrating to encounter one in which it does not.
I think Filippo's ReadOnly mode for the textbox is exactly what I was after.