Page 1 of 1

Emulate mobile keyboard

Posted: Thu Jan 14, 2016 4:58 pm
by tonymac
Droid LiveCode App or iPhone App

In a PERFECT world I would like the cursor to be visible in an unlocked field, the soft keyboard to be disabled (or just not visible), and place my own buttons representing the keys on the keyboard to enter text into a field. Is any of this doable?

Right now I'm looking at my next best solution of locking the field, moving the cursor (so to speak) by hiliting (selecting) a character at a time either moving left or right, noting which char is selected and then hitting one of my "keyboard" buttons which replaces the hilited character. For example, if a letter is hilited in my field and I hit the "B" key button, the hilited character gets replaced by the letter "B".

Kludgy but I think I can get this to work. Ideally though I would like to use my own "keyboard" buttons to enter text in an unlocked field and use left/right keys to move the cursor.

Thanks for any ideas you might have.

Re: Emulate mobile keyboard

Posted: Thu Jan 14, 2016 11:27 pm
by FourthWorld
Emulating OS keyboards well enough to not annoy users deeply accustomed to the one they're used to is very difficult.

What are you looking to do that can't be done with the built-in keyboard?

Re: Emulate mobile keyboard

Posted: Thu May 12, 2016 12:04 pm
by MaxV
Keyboard: when you create an Android virtual device, select hardware keyboard.

Re: Emulate mobile keyboard

Posted: Thu May 12, 2016 5:27 pm
by n.allan
I have done this in the past.

You need to lock the field which you have noticed will not longer receive the usual field messages. You now have to add custom handlers to the field for example....

Code: Select all

on virtualKeyDown tKey
      -- if there is hilitedText then replace it with the key
      if the selectedText is not empty then replace the selectedText of me with empty in me
      put tKey after me
end virtualKeyDown

on virtualBackspaceKey
     delete char -1 of me
end virtualBackspaceKey
you can then create a virtual keyboard with buttons that send messages to the field

Code: Select all

on mouseUp
     -- a button with label "1" will send virtualKeyDown 1 to the field
     send "virtualKeyDown" && the label of me to field "xxxxxx"
end mouseUp
You can tweak these to mimic your ideal field behaviour. I can confirm this method works on a real device. You will not be able to use the keyboard in the ide with these fields