2

Using a native Android control how would you automatically focus on a native android control. The MobileControlDo with the "focus" action only works on iOS. Is there another way to accomplish this in Android? I need to focus on a specific text field every time the user initiates an action.

I am being forced to use a native Android textbox control because I'm attaching a scanner to my tablet (via USB) and the built in Livecode control does not recognize the CRLF being sent from the scanner (other Android apps do). I also tried trapping it using KeyReturn, Rawkey,and KeyDown handlers but to no avail.

juergen d
  • 201,996
  • 37
  • 293
  • 362

4 Answers4

1

A LiveCode field (not a native Android control) should recognize a returnInField message as long as the field is in focus. Tap in the field to set the cursor and then activate the scanner. Note the the message is called "returnInField", not "keyReturn".

If that works you should be able to script "focus on field " to script the focus.

I've used scanners with LiveCode fields and they work, but I haven't actually tried it on Android. But if it sees your scanner, it should work.

Jacque
  • 416
  • 2
  • 7
  • OP suggested rawKeyDown fails which is why I asked for an elaboration on the problem. rawKeyDown should work in a LiveCode field. – Monte Goulding Mar 09 '13 at 06:14
  • The keyDown/rawKeyDown messages may only respond to physical keypresses. ReturnInField was recognized when I programmed a barcode scanner. But yes, we need more info. – Jacque Mar 09 '13 at 22:45
0

Use View.requestFocus() make sure the item is focusable (i.e. View.setFocusable()) i.e. textbox.setFocusable(true); textbox.requestFocus(); ?

There is also View.setFocusableInTouchMode() but this shouldn't be necessary as you are focussing programatically.

siliconeagle
  • 7,379
  • 3
  • 29
  • 41
0

Unfortunately I don't believe there is currently a solution to your problem

There may be a solution to the CRLF issue. Could you elaborate on than problem?

Monte Goulding
  • 2,380
  • 1
  • 21
  • 25
0

Try using the mobileControlDo command

mobileControlDo tFieldControlName, "focus"