Scan inputs with Opera Mobile 10
Asked Answered
Q

1

6

We have chosen the Opera Mobile for one PDA application, everything went well until we hit a problem with regards to taking a scanned input to one of the text fields.

The general way you'd approach this problem is by setting one textBox to have focus when the scan operation is performed.

UNFORTUNATELY, intentionally or unintentionally Opera is not supporting this. The focus is no-where when you enter in to the screen and there is no way of explicitely setting it. Worst comes next, you cannot detect the key-press events too, which makes it virtually impossible to take the input event from the scan operation.

I have no clue why Opera, one of the best acclaimed mobile browsers, does not support this.

These are the places the same question is asked over and over again,

http://dev.opera.com/forums/topic/255066

http://dev.opera.com/forums/topic/650332

http://dev.opera.com/forums/topic/384311

We have posted in the Opera Dev forum as well and it seems that they (so far) have no solution for this. If anyone has tried a workaround, we would be interested to hear the solution.

And please note that the solution in here is not working in Opera Mobile 10. I have not tried it in the proposed 9.X version.

Quietude answered 25/4, 2011 at 8:8 Comment(0)
Q
5

I found it myself. And here is how to do it.

Have a hidden button in the form

input type="button" id='myHiddenButton' visible='false' onclick="javascript:doFocus();" width='1px' style="display:none"

Have a javascript to get fired on the click event of the hidden button.

     function doFocus() {
         var focusElementId = "MyTextBox"
         var textBox = document.getElementById(focusElementId);
         textBox.focus();
     }

Have the button clicked using a javascript at the end of the document

     function clickButton() {
         document.getElementById('myHiddenButton').click();
     }

     setTimeout("clickButton()", 100);
Quietude answered 28/4, 2011 at 8:29 Comment(3)
This seems to work when you try to set the focus for the first time, but I could not make it work after more interactions in the same screenPuberulent
I actually realized: Would you know how to make it work after keyUp on a textbox? I have a barcodeReader which presses enter after typing its text on the textbox. This makes the textbox lose its focus. After that I can't replace focus on it nor from the blur event neither from the keyup Event (which I'm handling now to make a certain request to the server)Puberulent
you could extend the above approach a little to achieve that: basically inside the hidden button event handler try to set the focus to the next control and when it reaches the last control, activate the submit button. hope that helps!Quietude

© 2022 - 2024 — McMap. All rights reserved.