Emulate mobile keyboard

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
tonymac
Posts: 23
Joined: Thu Jan 05, 2012 9:17 pm

Emulate mobile keyboard

Post by tonymac » Thu Jan 14, 2016 4:58 pm

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.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Emulate mobile keyboard

Post by FourthWorld » Thu Jan 14, 2016 11:27 pm

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?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Emulate mobile keyboard

Post by MaxV » Thu May 12, 2016 12:04 pm

Keyboard: when you create an Android virtual device, select hardware keyboard.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

n.allan
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Mon Mar 12, 2007 12:06 pm

Re: Emulate mobile keyboard

Post by n.allan » Thu May 12, 2016 5:27 pm

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

Post Reply