iOS Question Strange text_changed behaviour

Discussion in 'iOS Questions' started by CaptKronos, Jun 27, 2019.

  1. CaptKronos

    CaptKronos Active Member Licensed User

    I have a requirement for a TextField to only accept integers. So I set:
    and to remove any typed decimal points I have the sub:
    Sub TextField1_TextChanged (OldText As String, NewText As String)
    If NewText.IndexOf(".")<>-1 Then
    "" 'no idea why this line is necessary
    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?
  2. Erel

    Erel Administrator Staff Member Licensed User

    Your best option is to use B4XFloatTextField and set the keyboard type to number.

    The TextChanged event in B4i actually happens right before the new text is actually set.

    You can call Sleep(0) instead of clearing the text.
  3. CaptKronos

    CaptKronos Active Member Licensed User

    Thanks. It's nice to know what's going on behind the scenes.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice