Android Question Overwrite mode in text input?

William Lancee

Well-Known Member
Licensed User
Longtime User
You can handle the override yourself. This is not pretty!

B4X:
Sub Globals
    Private kb As IME
    Private editBox As EditText
    Private editBusy As Boolean = False
End Sub

Sub Activity_Create(FirstTime As Boolean)
    editBox.Initialize("editBox")
    editBox.Color = Colors.White
    editBox.TextColor = Colors.Black
    editBox.Text = "Override this"
    Activity.AddView(editBox, 0, 0, 400dip, 50dip)
    kb.Initialize("kb")
End Sub

Sub editBox_TextChanged(olds As String, news As String)
    If editBusy Then
        editBusy = False
        Return
    End If
    editBusy = True
    Dim caretAt As Int = editBox.SelectionStart
    If caretAt > editBox.Text.Length-1 Then Return
    Dim oldText As String  = editBox.Text
    editBox.Text = oldText.SubString2(0, caretAt) & oldText.SubString(caretAt+1)
    editBox.SetSelection(caretAt, 0)
End Sub
 
Upvote 0
Top