Android Question EditText_EnterPressed different for soft and hard keyboards

Discussion in 'Android Questions' started by pfhrr, May 30, 2015.

  1. pfhrr

    pfhrr Member Licensed User

    I have code that has three edittext views.

    With soft keyboard after entering text in EditText3, when Finished is pressed the code executes as expected;
    • all text is cleared
    • focus shifts to EditText1.

    With a Bluetooth connected external hard keyboard after entering text in EditText3, when Return is pressed the following occurs;
    • all text is cleared
    • focus shifts to EditText1 briefly then
    • focus shifts to EditTest2

    Sub EditText3_EnterPressed

    EditText1.Text = "" ' clear input
    EditText2.Text = "" ' clear input
    EditText3.Text = "" ' clear input

    EditText1.RequestFocus ' shift focus back to first EditText view

    End Sub
     

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    Try this:
    Code:
    Sub MoveFocus
     EditText1.RequestFocus
    End Sub

    Sub EditText3_EnterPressed

    EditText1.Text = 
    ""   ' clear input
    EditText2.Text = "" ' clear input
    EditText3.Text = "" ' clear input

    CallSubDelayed(Me, 
    "MoveFocus")

    End Sub
     
  3. pfhrr

    pfhrr Member Licensed User

    Thanks Erel

    I tried your code but still get the same result - focus moves to EditText1.Text with soft keyboard, but focus moves to EditText1.Text briefly then EditText2.Text with external keyboard.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

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