iOS Question Strange text_changed behaviour

CaptKronos

Active Member
Licensed User
I have a requirement for a TextField to only accept integers. So I set:
B4X:
TextField1.KeyboardType=TextField1.TYPE_DECIMAL_PAD
and to remove any typed decimal points I have the sub:
B4X:
Sub TextField1_TextChanged (OldText As String, NewText As String)
    If NewText.IndexOf(".")<>-1 Then
        TextField1.Text="" 'no idea why this line is necessary
        TextField1.Text=OldText
    End If
End Sub

If I don't include the line TextField1.Text="" the decimal point doesn't get removed but with that line (actually it can be setting .Text to any value as long as its not OldText) then it works as expected. It seems that the text field needs to be set to a different value before the system spots that the value should be changed back to OldText. With B4A it works as expected and the TextField1.Text="" line is not necessary.

Is this expected behaviour for B4i?
 
Top