Hello everyone. First post ever here. So please be gentle.
The code i'm having trouble is this one:
IF i use the keyboard in my cellphone to enter a not existent code and press the "BUSCAR" button, it shows the ToastMessage indicating that it's offline, and it sets the focus on txtConteo properly. I can see the cursor blinking in the field whether it has a value or not.
BUT if i use a codebar reader, it reads the not existent code, shows the ToastMessage but no edit text view gets the focus. So, if i read another code inmediatly using the scanner, or if i press RETURN in the android keyboard, the app crashes. The app just closes.
I've tried changing the "code end char" on the reader, from ENTER (0x0d) to RETURN (0x0a). Same result.
The only way it works it's configuring the scanner to not sending an ENTER or RETURN. But the user is forced to press the button "BUSCAR".
With 30 codes to scan it's maybe nothing. But when there are 3000 codes to scan, it's not functional.
If anyone could shed a light on this issue, i would appreciate it.
Thanks in advance and BTW, what an excellent language is B4A. I'm loving it so far.
The code i'm having trouble is this one:
cmdBuscar_Click:
Private Sub cmdBuscar_Click
If FueraDeLinea Then
ToastMessageShow("Fuera de Linea",False)
MostrarControles(True)
txtConteo.RequestFocus
txtConteo.SelectAll
Else
Dim j As HttpJob
Dim Encontrado As Boolean
j.Initialize("j",Me)
j.PostString("http://" & APIServer.Trim & "/api/v1/buscarproducto.php","codigo=" & txtCodigo.Text)
j.GetRequest.SetContentType("application/x-www-form-urlencoded")
wait for (j) JobDone(j As HttpJob)
If j.Success Then
Dim Leido As String
Leido=j.GetString
Log(Leido)
If Leido.Trim.Length>0 Then
If Leido.Contains("fail")=False Then
Encontrado=True
ToastMessageShow("Encontrado",False)
Dim parser As JSONParser
parser.Initialize(Leido)
Dim root As List = parser.NextArray
For Each colroot As Map In root
Dim descripcion As String = colroot.Get("descripcion")
Dim equivalencia As String = colroot.Get("equivalencia")
Dim prodid As String = colroot.Get("prodid")
Dim cantidad As String = colroot.Get("cantidad")
Next
txtProdid.Text=prodid
txtEquivalencia.Text=equivalencia
txtDescripcion.Text=descripcion
txtExistencia.Text=cantidad
MostrarControles(Encontrado)
txtConteo.RequestFocus
txtConteo.SelectAll
Else
Encontrado=False
MostrarControles(Encontrado)
ToastMessageShow("No encontrado",False)
txtCodigo.RequestFocus
txtCodigo.SelectAll
End If
End If
Else
ToastMessageShow("No pude comunicarme con server API",False)
End If
j.Release
End If
End Sub
txtCodigo_EnterPressed:
Private Sub txtCodigo_EnterPressed
cmdBuscar_Click
End Sub
IF i use the keyboard in my cellphone to enter a not existent code and press the "BUSCAR" button, it shows the ToastMessage indicating that it's offline, and it sets the focus on txtConteo properly. I can see the cursor blinking in the field whether it has a value or not.
BUT if i use a codebar reader, it reads the not existent code, shows the ToastMessage but no edit text view gets the focus. So, if i read another code inmediatly using the scanner, or if i press RETURN in the android keyboard, the app crashes. The app just closes.
I've tried changing the "code end char" on the reader, from ENTER (0x0d) to RETURN (0x0a). Same result.
The only way it works it's configuring the scanner to not sending an ENTER or RETURN. But the user is forced to press the button "BUSCAR".
With 30 codes to scan it's maybe nothing. But when there are 3000 codes to scan, it's not functional.
If anyone could shed a light on this issue, i would appreciate it.
Thanks in advance and BTW, what an excellent language is B4A. I'm loving it so far.