Thanks in advance
Can you give more examples? If the field is hidden, then the concept of 'focus' on the field is hard to understand --- what are you trying to accomplish (and for the record, what is the platform/OS -- is this a Cordova (Hybrid) application, or are you using the native browser? and what platform?
You can't trigger the focus event on hidden field. It will even trigger an error with IE, according to jQuery doc.
"Attempting to set focus to a hidden element causes an error in Internet Explorer. Take care to only use .focus() on elements that are visible. To run an element's focus event handlers without setting focus to the element, use .triggerHandler( "focus" ) instead of .focus()."
Alternatively, you may set the field in a div and set it to transparent (opacity:0)
This is a mobile application for a scanning device. On the scan action a request is made to get data from Business Logic. In order to make the request we use a 'dummy' field which is populated from scan. We want to hide the field because it has no relevance for the user but keep the focus on this field at all time - this is to let the user to keep scanning without other button press and also we want to prevent the situation when the user touches the screen (in this situation we want to catch the tap event and set the focus back in the field).
Note that the field does not have the hidden property set - only the opacity is set to 0 so the user wil not see it.
What about populating a localStorage variable instead of a field?
We do as Edsel says. We populate a localStorage variable and then execute the service.
The application is deployed for android (we generate the apk file and install it on the scanner device).
Is it possible to direct the output of the scanner to a localStorage variable? The scan output goes into this 'dummy' field on each request - if the focus is not on it then the output of the scan is lost. In this case loosing the focus on the field prevents further scans.
I guess it depends on the scanner. Today, I am using the camera to scan barcodes (slower then an actual scanner) and an event fires when it reads a barcode. In this event I can do whatever I need such as write the scanned data to localStorage and then execute a service.
How are you handling populating this 'dummy' field now?
The barcode scanner service (Device service) can be mapped to UI components or to localStorage variables.
It looks like the scanner that you are using simulates user input as a keyboard. Could you confirm if that is the case?
How does it signal end of input? Does it use a return?
Perhaps, a solution could be to use a different component, for example, a button and detect the keystrokes (keypress, keyup, keydown events).
I hope this helps.
I tried creating a sample mobile app which uses Barcode device service that is shipped with Mobile App Builder (appdesigner.rollbase.com) and am able to store the data in local storage (and alert) variable and UI label.
We can use the same local storage variable for computation purpose by mapping to respective data elements (of OpenEdge backend) and perform the necessary operations.
Hope this helps.
Thanks and Regards,
We use the output of the scanner to fill in the input (as Edsel mentioned) - as I can see the output cannot be mapped to a localStorarge variable. The problem we have with the BarcodeService is that no event is triggered by the scan action.
There is no signal for the end of the input - we invoke our service when the barcode length (13) is reached (the input event is triggered for each digit in the barcode).
On invoke success the focus is set back on the input and keyboard blured.
>> The application is deployed for android (we generate the apk file and install it on the scanner device).
It sounds like this is not a 'normal' mobile phone, but a particular scanner device that supports Android applications. Would you mind sending a link to the device home site?
It sounds like the device itself effectively has a 'keyboard' proxy that is the scanner itself, so that the application 'thinks' it is keyboard input. In summary, you are trying to have the 'keyboard' only be the scanner (for one field), but Android is assuming that when you 'tap' on have focus on a field, then the field is 'keyboard enabled', so it is popping up the keyboard.
Is that a good summary?
Indeed, it is a scanner device (Motorola MC40) with Android OS. I think the configuration of the phone allows to fill any input with the value from the scan. This works ok in the mobile application - what we are missing is to prevent the user from leaving the input field while doing a multple scan (by accidentally tap on a different part of the screen). And for this we checked a couple of solutions:
- on Scan event apply focus on the input field (as suggested as well - the problem here is that we cannot catch that event on this device; the BarcodeService events are not triggered)
- on tap event re-apply focus on the input field (this was the initial question - as the tap event is not catched either; only the tap hold event)