Android Question FocusChanged Fires Unexpectedly

Discussion in 'Android Questions' started by Ronald Berardinis, Jul 22, 2019.

  1. Ronald Berardinis

    Ronald Berardinis Member Licensed User

    I have a warehouse application where the prompts flow in a certain order.
    Prompts work fine up to the point of saving a transaction.
    At that point the application jumps to a EditText box _FocusChanged.
    The application works fine when using 4in_Phone_Platform_24_Default_Platform from AVDManager.
    FocusChanged does not fire.
    But when using 4in_Phone_Platform_28_Defualt an unexpected text box focusChanged fires ??
    the behavior is strange.
    there is no RequestFocus to the errant textbox that is called.

    upload_2019-7-22_12-41-51.png
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    I'm not sure that I understand.

    1. Why does it matter that the FocusChanged event is raised? What are you doing with that event?
    2. How does your layout look?
     
  3. Ronald Berardinis

    Ronald Berardinis Member Licensed User

    when the focuschanged is raised, the process clears the screen.
    the application is prompt oriented.
    the program builds the screen as someone answers the prompt correctly.
    When the app starts, there is only one field on the screen. Basically a blank page.
    If the prompt is answered correctly, move to the next prompt.
    so the screen fills up with the required information and then when all questions are answered correctly, save prompt appears.
    however, the save prompt does not appear.
    The application jumps to another prompt previously answered and clears the screen from that prompt down.
    then has to start again.
    The app is now in a loop.
    this does not behave when using the 24 default.
    I have got around by putting the following in the focuschanged.
    notice the dSaveActive.
    I had to add to get the behavior I needed.

    Sub txtBin_FocusChanged (HasFocus As Boolean)
    If HasFocus And dSaveActive = False Then
    ShowNextPrompt("BN",sNo)
    End If
    End Sub

    but cannot explain why happening?
    is this a bug?

    also, is there a way to catch the "hasfocus" when click into the edittext box?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    The focus is managed by the OS so it is likely not a bug in B4A. Many things can cause the focus to change, your app should expect it.

    You can handle the Click event (it is not listed but it will work).

    The only thing that you should do when the focus is lost is validate the input and change the border color or something similar that will let the user know that the input is invalid. Let the user choose which view should be focused.
     
Loading...
  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