Private txtPhone As MaskedEditText
....
Sub txtPhone_FocusChanged(HasFocus As Boolean)
If HasFocus Then
If txtPhone.CompactText.Length < 9 Then 'while txtPhone.CompactText = "+7 () --"
CallSubDelayed3(Me, "Set_Cursor", txtPhone, 4) 'setting with a delay is OK. Direct txtPhone.SelectionStart = 4 works wrong.
End If
End If
End Sub
Sub Set_Cursor(v As MaskedEditText, i As Int)
v.SelectionStart = i
End Sub
Sub txtPhone_Filter(NewText As String, Position As Int, Replace As Boolean) As String
If txtPhone.CompactText.Length < 9 And Position > 4 Then 'if empty edittext
txtPhone.Text = NewText 'start typing from the first digit for sure
Return "" 'not to place the NewText into the tapped position
End If
Return NewText 'type new digit where the user needs to
End Sub