I'm a relative newbie here but I have a question relating to updating DrawText on a Canvas.
I input the text in an EditText box and this displays fine on the canvas using DrawText. However, if I want to delete some text then I want the text on the canvas to recognise when the backspace key has been pressed so that it deletes the characters/text on DrawText on the canvas.
I've done some searching on the forums but can't find anything to point me in the right direction. I've tried various methods but just can't get it to work.
Thanks for the pointers but the only KeyCode I could find was KEYCODES_BACK which references the Android back key and not the keyboard Backspace key which is what I was looking for.
This:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Msgbox("Backspace key pressed (not)","Result")
End If
End Sub
... brings up the MsgBox only when I press the back key.
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the eventKey
Log("KeyCode Pressed = "&KeyCode)
End Sub
... and got this in the log:
KeyCode Pressed = 4
so tried the process again with:
If KeyCode = KeyCodes.KEYCODE_4 Then
Msgbox("Backspace key pressed (not)","Result")
End If
Here's my code snippet as a Canvas test. What I want to do is make the text that appears on the canvas editable - for example, if the user presses the backspace key on the Android phone's keyboard then this is reflected on the text that appears on the canvas.
I want to be able to create signs, nameplates etc on the canvas area and then save the canvas as a graphic which can be sent to the manufacturer.
Sub TextBox1_TextChanged (Old As String, New As String)
c.DrawBitmap(B, Null, brect)
c.DrawText(New,25,35,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 20, Colors.Black, "LEFT")
i.Invalidate
End Sub
You need to redraw the background bitmap and then draw the text.