Page 1 of 2

Native control, hidding keyboard

Posted: Tue Nov 08, 2016 2:36 pm
by bangkok
I've got an Android (5.1) device with a barcode scanner (integrated).

Works fine.

I would like to hide the keyboard, when the focus is set on a native control.

Or to say it differently : is it possible to have a field that will receive the characters sent by the barcode scanner, without displaying the virtual keyboard ?

Re: Native control, hidding keyboard

Posted: Tue Nov 08, 2016 6:03 pm
by bangkok
Actually I have noticed that if I touch long enough on a native control (input)... the insertion cursor appears, there is focus, the content sent by the barcode scanner is displayed, but the keyboard doesn't show up.

So it's a progress !
;-)


Is there is a way to "emulate" this kind of long "mousedown" ? I could send the message, with an opencard for instance.

The native control would always keep the focus, but without the virtual keyboard.

Re: Native control, hidding keyboard

Posted: Tue Nov 08, 2016 9:10 pm
by FourthWorld
If the field is not to be used by the user to edit directly, does it need to be a native editable field?

Re: Native control, hidding keyboard

Posted: Wed Nov 09, 2016 9:54 am
by bangkok
FourthWorld wrote:If the field is not to be used by the user to edit directly, does it need to be a native editable field?
Yeah, I could use a regular livecode field instead.... but the behavior with the "long click" is different than with native control : the keyboard always shows up.

Re: Native control, hidding keyboard

Posted: Wed Nov 09, 2016 6:40 pm
by jacque
If the field is only for display, is there a reason not to use a locked LC field? Locked fields don't trigger the keyboard.

Re: Native control, hidding keyboard

Posted: Thu Nov 10, 2016 2:53 pm
by bangkok
jacque wrote:If the field is only for display, is there a reason not to use a locked LC field? Locked fields don't trigger the keyboard.
To summarize my conundrum

-if i use native control input
When i long touch the control, insertion point comes, keyboard doesn't show up : that's good
but when the focus is lost (if i display an answer dialog for instance), I need to long touch AGAIN to have insertion point back.
-> the command mobileControlDo "xxxx", "focus" doesn't work on Android

-if i use a regular livecode text field
Whenever the field gets the focus, with insertion point, the virtual keyboard is showing up. that's bad.

So I guess, the solution would be to have a command to force the focus on a native control input (it means to get the insertion point)

Or to programmatically emulate the "long touch" on a regular livecode text field.

Re: Native control, hidding keyboard

Posted: Thu Nov 10, 2016 5:35 pm
by jacque
It would be helpful to know why you need an insertion point without the keyboard. If it just to designate where incoming text should go, that can be done in the script.

Re: Native control, hidding keyboard

Posted: Thu Nov 10, 2016 6:13 pm
by bangkok
jacque wrote:It would be helpful to know why you need an insertion point without the keyboard. If it just to designate where incoming text should go, that can be done in the script.
Text is coming from the barcode reader, integrated to my android device.

It works the same way as a regular barcode scanner that you plug with on USB port to a PC : it emulates a "keyboard".

So on my Android device, I need a native control input, with focus, or a regular livecode field, in order to "catch" the text sent by the barcode reader.

Re: Native control, hidding keyboard

Posted: Thu Nov 10, 2016 6:25 pm
by jacque
Just a guess but try this:

Code: Select all

on keyUp pKey
  put pKey after fld "barcode" 
end keyUp

Re: Native control, hidding keyboard

Posted: Tue Nov 15, 2016 9:44 am
by bangkok
jacque wrote:Just a guess but try this:

Code: Select all

on keyUp pKey
  put pKey after fld "barcode" 
end keyUp
Unfortunately, if there isn't any focus (on a regular field or a native input control), KeyUp or KeyDown messages are not fired when the barcode scanner reads data.

Re: Native control, hidding keyboard

Posted: Thu Nov 17, 2016 11:36 am
by bangkok
OK i found a solution with regular livecode field

By using a... ask command !

Code: Select all

on opencard
select the text of field "barcode" ---- the virtual keyboard shows up
ask "Ready to work ?" ---- the virtual keyboard goes off
select the text of field "barcode" ---- the insertion point comes, ready to received scanned data, the virtual keyboard doesn't show up again
end opencard
This behavior would probably be seen as a bug.

I'm using LiveCode 8.1.1 with Android 5.1 device (tested on Android 4.1.1 device as well)

But right now, it solves my problem. :)

Re: Native control, hidding keyboard

Posted: Thu Nov 17, 2016 5:03 pm
by jacque
Did you try putting the keyUp handler in the card script? Keypress messages will go there if no field has focus.

Re: Native control, hidding keyboard

Posted: Thu Nov 17, 2016 9:58 pm
by bangkok
jacque wrote:Did you try putting the keyUp handler in the card script? Keypress messages will go there if no field has focus.
I did.

Actually, if there is no focus (no insertion point in a field or a native input control), the characters sent by the barcode reader do not fire up the keyUp message.

Same issue with the "hard" keyboard (my android device has a small numerical keyboard too).

At least, this is the behavior is see with LiveCode 8.1 and 8.1.1 Indy on Android 5.1.

By the way, it might interest some readers. Here is the device I use : OCBS-D8000 :

http://www.ocominc.com/products/2014-Ne ... D8000.html

We use this device for inventory and other applications. Connected via wifi to a MySQL server... and sending queries to a Odoo server ! Smooth.

I bought a few, from this company (in Hong Kong), via their website on Alibaba. 350 USD each. Fast delivery. No problem.

Re: Native control, hidding keyboard

Posted: Fri Nov 18, 2016 1:00 am
by jacque
That's a twist I didn't know, though it makes sense I guess that a mobile device wouldn't always be listening for keystrokes. On desktop, at least, the traversalOn property determines whether a field can get focus. I wonder what would happen if you tinker with turning it on and off. It's a long shot I admit. I'm thinking there has to be some way around the problem but like you, I can't think of it.

Re: Native control, hidding keyboard

Posted: Tue Mar 21, 2017 1:11 am
by pr1de
Dear Fellas,

Can someone give me a mighty hand of help, otherwise i'm just gonna kill meself. I can't make the bloody thing to check if "field" is not empty then delete everything and do keyDown. It empties the field but doesn't do any input whatsoever.
local tCard
local tFieldText

Code: Select all

on KeyDown theKey
   if field "Barcodes" is not empty then 
      put empty into fld "Barcodes"
      pass KeyDown
      put theKey after fld "Barcodes"
      put fld "Barcodes" into tFieldText
      put "A" & tFieldText into tCard
      go to card tCard
   else
      pass KeyDown
      put theKey after fld "Barcodes"
      put fld "Barcodes" into tFieldText
      put "A" & tFieldText into tCard
      go to card tCard
   end if
end KeyDown
However, if I run this code it works perfectly!

Code: Select all

on KeyDown theKey
      put theKey after fld "Barcodes"
      put fld "Barcodes" into tFieldText
      put "A" & tFieldText into tCard
      go to card tCard
end KeyDown
Thank you