Android Question not responding to cr sent from scanner

simon w

Member
Licensed User
Longtime User
Hi,
i hope this a simple question.
i have a simple app with 2 labels,2 textboxes , 6 buttons and 1 listview.
the data entered into the textboxes comes from a scanner with a <cr> at the end. from box 1 to box to jumps correctly. in order to have it go to first texbox. at the second box i added
Sub txtLocation_EnterPressed
txtPart.RequestFocus
End Sub
however the focus does not change.
shouldn't the EnterPressed pickup the <CR> sent from scanner?
what am i doing wrong?
thanks in advance
Simon
 

stevel05

Expert
Licensed User
Longtime User
It would make sense that the EnterPressed is only fired when the Enter button is pressed on the keyboard. So if you are amending the content by code the event will never fire.
After a test it appears that the TextChanged event also only responds to keyboard entry.

Can't you parse the incoming data and add it to the correct EditText?
 
Upvote 0

simon w

Member
Licensed User
Longtime User


Thanks for your response!
the data is coming from a bar code scanner not from code. i would have to trap all incoming data.
i am somewhat confused. from first text box to second text box. it understands that a <cr> was entered.
why doesn't it recognize it when i want to trap it? can it be a timing issue?can it be that it already moved out of focus before trap ?
thanks again for your input.
Simon
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
How are you sending the incoming data to the first Edittext?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Ah OK, then I'm not going to be able to help. I've not used a Bar-code scanner. Hopefully someone will have solved this and let you know.
 
Upvote 0

simon w

Member
Licensed User
Longtime User
i"m using a Bluetooth bar-code scanner. it in essence acts like it was entered at the keyboard.

i did some further testing. i ran it in debug mode and it does trap it. i think the issue is that it returns to caller which is the text box and keeps it's focus.

in other words:

Sub txtLocation_EnterPressed
txtPart.RequestFocus
End Sub

this gets invoked , just the RequestFocus doesn't.

any ideas?

thanks again
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You could try using callsubdelayed to call a sub that requests the focus. It is not always possible to do some of these things in a callback sub.
 
Upvote 0

simon w

Member
Licensed User
Longtime User
You could try using callsubdelayed to call a sub that requests the focus. It is not always possible to do some of these things in a callback sub.
I"m not sure of the syntax. how would i use callsubdelayed with txtPart.RequestFocus
Thanks
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You would have to set a sub:
B4X:
Private Sub RequestFocus
      txtPart.RequestFocus 
End Sub

Then in the callback:
B4X:
CallSubDelayed(Me,"RequestFocus")

Or similar
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…