Sub Globals
Private btnLeft As Button
Private btnRight As Button
Private edtTest As EditText
Private CursorPosition As Int 'variable keeping the current cursor position
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
End Sub
Sub btnLeft_Click
Private i As Int
edtTest.RequestFocus 'sets the focus to show the cursor
i = edtTest.SelectionStart 'gets the current cursor position
CursorPosition = Max(i - 1, 0) 'removes one till 0
edtTest.SelectionStart = CursorPosition 'sets the new position
End Sub
Sub btnRight_Click
Private i As Int
edtTest.RequestFocus 'sets the focus to show the cursor
i = edtTest.SelectionStart 'gets the current cursor position
CursorPosition = Min(i + 1, edtTest.Text.Length) 'adds one till text length
edtTest.SelectionStart = CursorPosition 'sets the new position
End Sub