View Full Version : Bluetooth handheld scanner

10 Jan 2011, 2:35 PM
Hi guys,
This may seem like a weird one, but I hope that after I explain it, it'll become a little more clearer.
I am writing an app in sencha touch 1.0.1. I have myself a panel (fullscreen) and I have a docked toolbar (top) with a textfield and several buttons.
the business requirement is: their users will be scanning barcodes with a bluetooth handheld scanner (that is paired with the ipad). when they scan a barcode, i would like my app to capture the input and simply log it to the console.

now, currently, the only way this is possible is if you tap on the textfield (which brings up the keyboard) and then scan the barcode. but i would like to not tap anything, but simply scan the barcode and, whether it's the textfield listening for input or some other widget, i simply want to capture the input and write it to the console.

their requirement is simply to scan barcode after barcode without touching the screen.
is that possible?

10 Jan 2011, 3:29 PM
I would also be interested to see if anybody has a solution for this I've been trying to implement something similar. Problem starts when onfocus does not work on mobile safari.
Next I tried using event listeners for keypress but unless you are in the textfield it will not work. It works fine on the desktop where if you add a listener for keypress it will fire even if no textfield is selected. Anybody knows on how to get the event listeners working on mobile safari?

I've also tried window.captureEvents which I understand is now supported on iOS 4.2 but still no luck unless you are in a textfield.

10 Jan 2011, 5:24 PM
Hi ed.canas,
Yeah, I've been trying to attach events to the window, like this:

window.onkeypress = function() {
console.log('onkeypress fired');
};so that when the handheld scanner scans the barcode, it would detect an input. Now this works in Safari (on the desktop), but not on the iPad. You're right - they did say this would be in iOS 4.2. Weird.

Anyone else got this problem?
Any solutions?

I'll keep plugging away at it and let everyone know my outcomes.

11 Jan 2011, 4:10 PM
I found a link to another thread where others have the same issue. You can see it here:


For me, I don't think it's a viable solution, perhaps others have got some suggestions.

11 Jan 2011, 4:13 PM
Hi guys,
I have found a link to another forum where others have the same issue. It can be found here:


It's not a proper solution, especially for me; I was wondering if others have any suggestions.
Look forward to hearing from you all.

11 Jun 2012, 1:47 AM
I am having the same issue, however with Sencha touch 2 the field focus capability is much better. I have managed to put listeners in place on the container being focused, blurred or tapped to then push focus to a text field that I have created.

If i am typing in numbers to store it will always return focus and just keep going and storing numbers as fast as i can type.

When i scan however the field always loses focus after my 7 digit number is stored. I have added listeners all over the shop to return focus to the text field, even on text field blur, but to no avail.

It seems to come down to how the scanner hides the keyboard. To check this i have added some console logging when the field gets focus and the same when the field loses focus this log doesn't show that the field has lost focus after the scan.

This is similar to if you click on Error Log, the field doesn't register that its lost focus but he cursor is not in the field when you return. I will start exploring listening on the rendering of the field and see if this helps, but any other ideas or solutions found would be amazing.