18 Nov 2013 3:36 AM #1
Barcode scan without textfield
Barcode scan without textfield
I was not sure if this is the right place but here it goes;
I have a handheldterminal with an integrated barcode scanner which emulates keyboard input. Because of this i was able to create a EventListener for a keyDown event throughout the app so whenever a barcode is scanned, the event handler register this as a keyboard event. We want this because the scanning of a barcode will be used to navigate throughout the app and for fast navigating we don't want to make the user select a textfield first.
Each character from the barcode is a individual keyboard event and throught a fixed pre- and suffix(slashes at the beginning and end; \12345/) on the barcode i'm able to detect if a scan is taking place rather than the user is just typing. This works outside of the focus on a textfield and i'm able to get the barcode but i run into a problem; I'm currently testing this on a handheldterminal with Android 2.3 so my options for a webkit browser are limited. I'm currently using Dolphin browser which seems to be able to render a Sencha Touch app fine. But the problem is that whenever i scan and i'm not focused within a textfield, the browser sees this keyboardevent and interprets this as some sort of search event and fills the address bar with the barcode where i'm then able to use a search engine. This also isn't even consistent; sometimes only parts of the barcode are filled in, for example; the first time i scan it always seems to take just the '\' from the barcode, but after that it seems to take '00504/' or sometimes even just the '4'.
If i'm focused within a textfield and the digital keyboard is up, it seems to work just fine and it stays within the page. I tried to set hidden = true on a textfield and still set the focus on it but this didn't work. Whenever the textfield becomes read-only, the browser just takes over and fills the address bar with the barcode.
I'm running out of ideas to make this work, i'm hoping this is an issue within Sencha(Sorry :P) but i think it just has to do with how the browser interprets a keyboard event outside of a textfield/textarea. I was able to test it on the standard browser of the device but the same thing happens. Since i'm running Android 2.3 i'm unable to test it on other browsers and i don't have the option to get a handterminal with Android 4.0 and we kinda want this app to work on a wide variety of devices.
I hope some of you may have some ideas about this problem and maybe can help with me further.
21 Nov 2013 2:33 PM #2
Moved to Sencha Touch 2.x Discussion forum to get the right eyes seeing this.Get on the Fast Track with Sencha Training http://sencha.com/training
25 Nov 2013 7:14 PM #3
Been awhile since I've played with it but came across the same issue. Seems the browser "optimizes" itself by ignoring key events when it doesn't think a keyboard should be present :\. I was mainly working on iPhone but had to have focus in a field. I just thought of it now and never tried it but you could possibly give the field focus but have it behind another control so it isn't visible.
18 Dec 2013 3:33 AM #4