Page 1 of 1

ASK Command Return Button means "OK"

Posted: Sun Jan 14, 2018 6:51 pm
by Manu9351
is there any possibility to press the OK button at an ASK-Event with the ENTER Button on a mobile device?
My situation is: I have an Bluetooth-Barcode-Reader, so the App asks with an Ask-command for a barcode.
EAN screenshot.jpg
I scan a barcode with the bluetooth device, and the device inserts a "RETURN" after the line of numbers automatically. But i want that the "RETURN" means "PRESS OK" and not "Go to line 2" like i press Enter in a word document.
Anyone have an idea what i mean?

THANK YOU!!

Re: ASK Command Return Button means "OK"

Posted: Sun Jan 14, 2018 8:50 pm
by quailcreek
I think I understand what you are asking. Maybe post that part of your code that is setting the return char.

Re: ASK Command Return Button means "OK"

Posted: Sun Jan 14, 2018 9:05 pm
by Manu9351
quailcreek wrote:
Sun Jan 14, 2018 8:50 pm
I think I understand what you are asking. Maybe post that part of your code that is setting the return char.
That's just this, where i have to set the return code?

Code: Select all

global EANTemp
on mouseUp
   ask "Bitte scannen Sie den EAN Code!" //English: Please scan the barcode
   put it into EANTemp
   put it into field "field_EAN"
end mouseUp

Re: ASK Command Return Button means "OK"

Posted: Sun Jan 14, 2018 9:26 pm
by quailcreek
I've written a couple of scanner apps so I understand that it puts a RETURN char at the end. This is how I handle it.

Code: Select all

 if the last char of EANTemp is RETURN then delete the last char of EANTemp

Re: ASK Command Return Button means "OK"

Posted: Sun Jan 14, 2018 9:41 pm
by Manu9351
quailcreek wrote:
Sun Jan 14, 2018 9:26 pm
I've written a couple of scanner apps so I understand that it puts a RETURN char at the end. This is how I handle it.

Code: Select all

 if the last char of EANTemp is RETURN then delete the last char of EANTemp
The return is not thw problem, its possible to turn this last return in the properties from the scanner off.

But i want the the app understands instead of the return "press OK Button"

Re: ASK Command Return Button means "OK"

Posted: Sun Jan 14, 2018 9:57 pm
by quailcreek
Ok, so you want the return char to end the ask interaction without letting the user examine the scan data. I see. I'm not sure how to do that.

Re: ASK Command Return Button means "OK"

Posted: Sun Jan 14, 2018 10:17 pm
by Manu9351
quailcreek wrote:
Sun Jan 14, 2018 9:57 pm
Ok, so you want the return char to end the ask interaction without letting the user examine the scan data. I see. I'm not sure how to do that.
correct, that's what i want. The scan data MUST be right, because the barcode scanner enters the line of numbers. No need to examine it before return

Re: ASK Command Return Button means "OK"

Posted: Mon Jan 15, 2018 9:15 pm
by jacque
I haven't tried it, but an Answer dialog may work since it doesn't have an editable field.

Re: ASK Command Return Button means "OK"

Posted: Mon Jan 15, 2018 9:48 pm
by Newbie4
Instead of a button, just put this code into the script of the field "field_EAN":

Code: Select all

on returnInField
   (put your code to process the number here)
end returnInField
and

Code: Select all

on enterInField
   (put your code to process the number here)
end enterInField
it will handle the number when it receives the "return" or "Enter" code from the scanner

Re: ASK Command Return Button means "OK"

Posted: Tue Jan 16, 2018 12:15 am
by jacque
From the looks of it, the script is using the built-in Ask dialog on Android, which isn't editable.

Re: ASK Command Return Button means "OK"

Posted: Tue Jan 16, 2018 12:32 am
by Newbie4
But the ask is in the button. I assume that the user presses a button to select if they are using a scanner or entering the number by hand. My point is that he does not need the buttons to choose. All he needs is a field with that code in it. It will handle a number entered manually or using a scanner.

If he can not remove the "Ask", he can program his scanner to work with the button.
Most scanners have a way to program them for different types of barcodes (code 39, 128, UPC, etc) They also come with a way to include/exclude a return with the number. If the scanner is not programmable, there is usually scan codes to set them up. If he has the scanner add 2 returns after the number, the button will work.

Re: ASK Command Return Button means "OK"

Posted: Tue Jan 16, 2018 4:51 pm
by AxWald
Hi,

I can see the problem - the signal from the scanner is coming as keyboard input, and has to be caught somewhere. But as soon as you focus on any field (on mobile), this nasty keyboard pops up, covering half the screen.

This way, opening an ask dialogue is a good way to fetch it. Only now the user sees some strange data coming in, and has a great opportunity to manipulate it, and mess the things up. So it would be fine if the incoming data itself would "hit the OK button", but I assume there's no way to do it.

Would I have to do this, I'd try the following approach:

To scan, the user has to press a "EAN scannen" button:

Code: Select all

global gScanData
on mouseUp
   put empty into gScanData
   go card "ScanPage" of this stack
end mouseUp
Card "ScanPage" only has the prompt "Bitte jetzt scannen!" ("Scan now!"), a "Cancel/ Abbrechen" button, and 2 handlers in the card script:

Code: Select all

global gScanData
on keydown what
   put what after gScanData
end keydown

on returnkey
   go cd 1 of this stack  --  or where ever ...
   ScanDone
end returnkey
Card 1 now has the last handler:

Code: Select all

global gScanData
on ScanDone
   put gScanData  --  or do something useful with it ;-)
end ScanDone
Caution: Keydown only reports chars and numbers, so if the scanner sends control chars this doesn't work. Use RawKeyDown in this case.
And - this isn't tested, it's just an idea. So it may not work at all ...

Have fun!

Re: ASK Command Return Button means "OK"

Posted: Tue Jan 16, 2018 5:16 pm
by Manu9351
Newbie4 wrote:
Tue Jan 16, 2018 12:32 am
But the ask is in the button. I assume that the user presses a button to select if they are using a scanner or entering the number by hand. My point is that he does not need the buttons to choose. All he needs is a field with that code in it. It will handle a number entered manually or using a scanner.

If he can not remove the "Ask", he can program his scanner to work with the button.
Most scanners have a way to program them for different types of barcodes (code 39, 128, UPC, etc) They also come with a way to include/exclude a return with the number. If the scanner is not programmable, there is usually scan codes to set them up. If he has the scanner add 2 returns after the number, the button will work.
i've tried to use just the field below with the code of the button, i can write the code manually, that's no problem. But when i scan it with the barcode reader, no line of number appears in the field.. so the button was my compromise solution. But i'll try it again tomorrow with the code from you.

& yes, my scanner is programmable to include/exclude a return after the numbers. But the return after the numbers causes a jump into the 2nd line, but no "return" like an OK.

Re: ASK Command Return Button means "OK"

Posted: Tue Jan 16, 2018 6:47 pm
by Newbie4
Are you using a "software" scanner or a hardware scanner with your Android phone?

I tested both solutions and they work on a computer. My scanner does not connect/input into my cellphone so I could not fully test it under Android. You might have to set the focus to the field and turn off the keyboard. The code works, so it must be a problem with the scanner or the Android platform.
You might have to experiment some more or post a question on the Android forum. Maybe someone can help you there.

These are the two methods that worked for me:

1. With the button method and using the Ask command, you have to program the scanner to include 2 "returns" after the number. One to end the input and the second one for the "Ok" button of the dialog.

You can leave the code as it is

Code: Select all

global EANTemp
on mouseUp
   ask "Bitte scannen Sie den EAN Code!" //English: Please scan the barcode
   put it into EANTemp
   put it into field "field_EAN"
end mouseUp
2. With the field method you have to add the "returnInField" and "enterInField" scripts to the field to limit the input to one line (the number) and return control to your program. You only need to program the scanner to include only 1 "return" after the number. You do not need any buttons for this method and it also enables you to manually input the numbers.

remove the button and just use the field

in the script for the field "field_EAN" add this:

Code: Select all

on returnInField
   (put your code to process the number here)
end returnInField
on enterInField
   (put your code to process the number here)
end enterInField

Make sure that your scanner is working with a simple test field. If you do not see any numbers, then try setting the focus to that field and see if that makes a difference.
Good luck and come back with what happens.