Android Question Simulate Enter keypress

dim

Member
Licensed User
Hi all,
I have an edittext with an "EnterPressed" event that does something (beeps).
Using the device's keyboard I can write in the edittext and then pressing the device's keyboard's "Enter key" the EnterPressed event is fired fine.

Now I added a button that generates a string and pressing it, code is :
B4X:
Button1.Text = "abc"
EditText1.Text = Button1.Text

So the text that the button generates is written in the Editext. No EnterPressed event so far.
So I changed code to :
B4X:
Button1.Text = "abc" & CRLF
but still EnterPressed event is not fired.
What I am doing wrong ?
Thank you
 

dim

Member
Licensed User
Thank you Erel, but may I ask what is the actual difference between calling the "Enterpressed" myself and adding the CRLF in the end of the string ?
 
Upvote 0

dim

Member
Licensed User
So, if I use barcode scanner that sends CRLF automatically after the string that it scans, it wont automatically submit in my android app ?
 
Upvote 0

fixit30

Active Member
Licensed User
Yes. That is correct.

It would be better to use the barcode scanner in SPP mode and use AsyncStreams.
 
Upvote 0

dim

Member
Licensed User
Thank you. As I wrote, the barcode scanner includes the CRLF after every string it sends. If the component cannot use it, maybe it's better me to try to read it in the string that it's been written. Is that correct ?
 
Upvote 0

fixit30

Active Member
Licensed User
You could try handling the EditText1_TextChanged event. It seems to work!

B4X:
Sub EditText1_TextChanged (Old As String, New As String)
    If New.EndsWith(CRLF) Then
        EditText1_EnterPressed
    End If
End Sub
 
Upvote 0

dim

Member
Licensed User
Thank you guys, tomorrow I receive my barcode scanner and will test it.
BTW, Erel your development platform B4* rocks !
 
Upvote 0
Top