Android Question Blutooth Barcode Reader, problem with cursor movement

Discussion in 'Android Questions' started by incendio, Mar 20, 2015.

  1. incendio

    incendio Well-Known Member Licensed User

    Hi all,

    I have app that use bluetooth barcode reader - set as a HID.
    On my layout, there are 3 object :
    1) txt1 - Edit Text
    2) txt2 - Edit Text
    3) btn1 - Button

    I want to put cursor always on txt2 after do the scan, so this the code in txt2
    Code:
    Sub txt2_EnterPressed
       
    If(txt2.Text = ""Then Return
       txt2.Text = 
    ""
       txt2.RequestFocus
    End Sub
    When cursor placed in txt2, after the scan, something strange happen with cursor.

    If i put this code on Activity_Create
    Code:
    FieldOrder.Initialize(Array As Object(txt1,txt2),True)
    Cursor jump to txt1.

    change code on Activity_Create to
    Code:
    FieldOrder.Initialize(Array As Object(txt1,txt2),False)
    Cursor disappear, and while cursor not visible, do the scan again, raised clicked event in btn1.

    It seem that the barcode sent twice Enter/Tab keys. Can someone help me to fix this?

    Thanks in advance.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. incendio

    incendio Well-Known Member Licensed User

    Still not working.

    I am using this code on Activity_Create
    Code:
    FieldOrder.Initialize(Array As Object(txt1,txt2),False)
       KYB.Initialize(
    "KYB")
       KYB.AddHandleActionEvent(txt2)
    Remove codes on txt2_EnterPressed replaced it with
    Code:
    Sub KYB_HandleAction As Boolean
        
    Dim e As EditText
        
    Dim Barcode As String
        e = 
    Sender

        Barcode = e.Text

        
    If(Barcode = ""Then Return False
       
        
    If(InputNotOk(Barcode)) Then
            
    MsgBox("Not Valid Input","")
        
    else
           SaveBarcode(Barcode)
           e.Text = 
    ""
        
    End If   
       
    Return True
    End Sub
    Cursor disappear, do the scan again, clicked event on btn1 raised.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Do you mean that the focus moves to btn1 after the scan?
     
  5. incendio

    incendio Well-Known Member Licensed User

    Yes.

    After the scan, cursor dissapper, and without do nothing, do a scan again, has an effect like touching btn1.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    You can always use a "brute force" solution and add a timer to move the focus to the text field.
     
  7. incendio

    incendio Well-Known Member Licensed User

    Don't think that timer would be applicable.

    This is a bulk scan operation. On a normal situation, barcode reading is very fast, less than 1 sec and users don't looks at a screen after do the scan.

    Users scan right away after a beep from a barcode. If user must looks every time at a screen after doing a scan ( to make sure that cursor has focus on text field), it is really slow down the operation.
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Use a timer with 50 or 100ms interval.
     
  9. incendio

    incendio Well-Known Member Licensed User

    I have implemented other solution. Still in testing now, if it is fail will try using timer.

    Thanks anyway for your idea.
     
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