For this application I’m not generating the barcode so they’re being read right from the product packaging. The scanner I have to work with puts a CR after the last char of the barcode so I’m using rawKeyDown to capture that. Is that typical of all BC readers to add the CR in this situation?
I have a preOpenCard script that set the focus on a fld for the initial scan. If the fld has focus before the scan, all the chars of the barcode are read into the fld. The problem I’m having is that if the fld does not already have focus naturally it needs to be set. With the code below it sets the focus but the first char of the barcode is missing. This also happens if I just type from the keyboard without the fld having focus. Is there a better way to set the focus on the fld before the keyDown or rawKeyDown?
This is in the card script. If you put this into the card script and have a fld named barcode on the cd. Then, with the fld not having focus, type a key on the keyboard. Then type a second key.
Code: Select all
on KeyDown
if fld "Barcode" is not the focusedObject then
focus on fld "Barcode"
pass KeyDown
end if
pass KeyDown
end KeyDown
on rawKeyDown theKey
if theKey is 65293 OR theKey is 65421 then
delete last char of fld "Barcode"
put fld "Barcode" into sBarcode
manageBarcode
put empty into fld "Barcode"
else
pass rawKeyDown
end if
end rawKeyDown