Android Question Blutooth Barcode Reader, problem with cursor movement

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
B4X:
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
B4X:
FieldOrder.Initialize(Array As Object(txt1,txt2),True)
Cursor jump to txt1.

change code on Activity_Create to
B4X:
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.
 

incendio

Well-Known Member
Licensed User
Try to use the HandleAction event from the IME library instead of EnterPressed: http://www.b4x.com/android/forum/th...-keyboard-with-the-ime-library.14832/#content

This will allow you consume the "enter event".
Still not working.

I am using this code on Activity_Create
B4X:
   FieldOrder.Initialize(Array As Object(txt1,txt2),False)
   KYB.Initialize("KYB")
   KYB.AddHandleActionEvent(txt2)
Remove codes on txt2_EnterPressed replaced it with
B4X:
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.
 

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.
 

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.
 

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.
 
Top