self opening keyboard

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ronbird
Posts: 17
Joined: Wed Sep 18, 2013 9:27 am

self opening keyboard

Post by ronbird » Thu Jan 22, 2015 4:01 pm

Hi all,
Working on an Android application and I'm trying to have a keyboard open automatically on openCard. I dont want the user to have to touch the text field to have to launch the keypad, I want the keypad to be there when the card opens. Can anyone help? Thanks Ron.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: self opening keyboard

Post by Klaus » Thu Jan 22, 2015 4:05 pm

Hi Ron,

not sure, but since the keyboard will only pop up when a text entry field is opened,
you should try something like this:

Code: Select all

on opencard
  focus on fld "name of your field here"
  ...
  ## or maybe:
  ## select text of fld "name of your field here"

  ## or 
  ## select BEFORE text of fld ...
  ## select AFTER text of fld ...
end opencard
Best

Klaus

ronbird
Posts: 17
Joined: Wed Sep 18, 2013 9:27 am

Re: self opening keyboard

Post by ronbird » Thu Jan 22, 2015 5:29 pm

on opencard
focus on fld "name of your field here"
end opencard

works a treat, I did not realise it would be so easy.
Thanks Ron

ronbird
Posts: 17
Joined: Wed Sep 18, 2013 9:27 am

Re: self opening keyboard

Post by ronbird » Thu Jan 22, 2015 7:18 pm

supplemental ;-)
I have focus in the first field, the keyboard automatically opens and on pressing return I can move to the next field.
The next press of return I want to go to the next card. I wrote this (and many others like it):

on returninfield
--
if environment() = "mobile" then
if focus = "Field_Phone#" then
focus on fld "field_amount"
end if
end if
--
if focus = fld "field_amount" then
go next
end if
--
end returninfield

but this does not work. Any leads please, thanks Ron

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: self opening keyboard

Post by Klaus » Thu Jan 22, 2015 10:02 pm

Hi Ron,

FOCUS is a command, not a property, use "the selectedfield", see dictionary.

Try something like this:

Code: Select all

on returninfield
..
## I avoid nested IFs wherever I can :-)
if environment() <> "mobile" then
  pass returninfield ## or EXIT returninfield
end if
if the short name of the selectedfield = "Field_Phone#" then
   focus on fld "field_amount"
end if
--
if the short name of the selectedfield = fld "field_amount" then
  go next
end if
--
end returninfield
Best

Klaus

ronbird
Posts: 17
Joined: Wed Sep 18, 2013 9:27 am

Re: self opening keyboard

Post by ronbird » Fri Jan 23, 2015 10:49 am

Well this is interesting....
The code you suggest navigates from one field to the next but does not navigate to the next page.
I noticed that line 7 misses out 'fld'
'if the short name of the selectedfield = "Field_Phone#" then'
so I removed it from
'if the short name of the selectedfield = fld "field_amount" also.
Then the code navigated from the first field "Field_Phone#" to the next page missing out the field "field_amount"
I placed the term 'fld' from the line it was missing from, and then nothing happens.
Moving from a field to another page is important, and I can fake the look to make it appear the user is still on the same page, and has only moved from one field to the next. Due to time constraints this is the route I shall take.
However I shall look at the script later to see if I can get it to work correctly.
Thanks for your help Klaus, Ron

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: self opening keyboard

Post by Klaus » Fri Jan 23, 2015 1:19 pm

Hi Ron,

yep, sorry, one "fld" was too much and "made in a hurry".
The SHORT name of an object does of course not contain its TYPE decriptor, but you knew that 8)

And I did not suggest code, only correct syntax. :D
No idea if that really works, however opening a field to go to the next card does not seem to be the right way to me.


Best

Klaus

ronbird
Posts: 17
Joined: Wed Sep 18, 2013 9:27 am

Re: self opening keyboard

Post by ronbird » Tue Mar 10, 2015 3:14 pm

hi all
I've used the code below once before and it worked.
I'm trying to use the same code again and when I press the Android keyboard return all I get is a return in the selected field and not navigating to the next card. Any thoughts as to where I've gone wrong? You will see in the code I've tried various options, and more than you see there.
Trial file, Keypad1.livecode.zip, uploaded

on returninfield
--
if environment() <> "mobile" then
pass returninfield
## or EXIT returninfield
end if
--
--if the autoTab of the target then
--go next card
--end if
--
--if the short name of the selectedfield = field "field3" then
if the short name of the selectedfield = "field3" then
go next
end if
--
end returninfield
Attachments
Keypad1.livecode.zip
(2.6 KiB) Downloaded 227 times

ronbird
Posts: 17
Joined: Wed Sep 18, 2013 9:27 am

Re: self opening keyboard

Post by ronbird » Wed Mar 11, 2015 11:51 am

Ok. I've sorted it, and the answer is:
--
on returninfield
--
if environment() <> "mobile" then
answer "is environmentmobile?"
pass returninfield
end if
--
if the short name of the selectedfield = "field3" then
go card"ONE"
end if
--
end returninfield

:D

ronbird
Posts: 17
Joined: Wed Sep 18, 2013 9:27 am

Re: self opening keyboard

Post by ronbird » Wed Mar 11, 2015 11:52 am

Ok. I've sorted it, and the answer is:
--
on returninfield
--
if environment() <> "mobile" then
pass returninfield
end if
--
if the short name of the selectedfield = "field3" then
go card"ONE"
end if
--
end returninfield

:D

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: self opening keyboard

Post by jacque » Wed Mar 11, 2015 7:23 pm

Glad it's working, but be aware that naming cards as numbers is a bad idea that can cause all kinds of trouble later. The quotes around the name save you in this case, but it would still be better to use a different name if you can.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply