Page 1 of 2
How to move input fields covered by virtual keyboard
Posted: Mon Jun 18, 2018 9:27 pm
by Texter
Hi
I am new with Livecode but I have created an app for me that work fine on a tablet.
The only thing is if I enter an imput field and the vitual keyboard appears the field is covered by the keyboard.
I read different ways for a solution but I did not understand how they work or where to put the code.
Can someone explain it to me or give me an instruction.
Thank you
Texter
Re: How to move input fields covered by virtual keyboard
Posted: Mon Jun 18, 2018 9:51 pm
by jmburnod
Hi,
You have to set the rect of your fld when keyboardActivated is sent.
Something like that:
Code: Select all
on keyboardActivated
put the rect of fld "myFld" into tRect
put 350 into item 4 of tRect -- 350 of what you want for bottom of fld
set the rect of fld "myFld" to tRect
end keyboardActivated
Best
Jean-Marc
Re: How to move input fields covered by virtual keyboard
Posted: Mon Jun 18, 2018 10:46 pm
by Texter
Thank you Jean-Marc
I will try it tomorrow
Texter
Re: How to move input fields covered by virtual keyboard
Posted: Tue Jun 19, 2018 1:18 pm
by Texter
Hello Jean-Marc
Tryed your code but I think the better way for me is to set the location and bring it back after input of the field.
But however thank you
Texter
Re: How to move input fields covered by virtual keyboard
Posted: Tue Jun 19, 2018 6:34 pm
by Klaus
I'm sure Jean-Marc meant this more as an example for when and what can be done in general
and not the actual solution for your problem!

Re: How to move input fields covered by virtual keyboard
Posted: Thu Jun 21, 2018 7:10 am
by Texter
Hi
Thanks to Jean-Marc and Klaus
I use now
put the location of field Field1 into tLocold
put 500,50 into tLoc
set the location of field Field1 to tLoc
and set it back to tLocold if the keyboard disappear
Is there a way to use the field ID as a variable instead of the name?
Like
put the location of field gFieldnumber into tLocold
put 500,50 into tLoc
set the location of field gFieldnumber to tLoc
Texter
Re: How to move input fields covered by virtual keyboard
Posted: Thu Jun 21, 2018 9:26 am
by mrcoollion
This works
Code: Select all
put the ID of fld "TheField" into tFieldID
answer fld ID tFieldID
So I guess the following should work (tested it and it works)
Code: Select all
put the location of field ID gFieldnumber into tLocold
put 500,50 into tLoc
set the location of field ID gFieldnumber to tLoc
Or try this.
Put a field in your card with the name "TheField" and put some text into it and place a button above this field with the following code.
Code: Select all
on mouseUp
put the ID of fld "TheField" into tFieldID
put the location of field ID tFieldID into tLocold
answer "The Text in field = " & FLD ID tFieldID
answer "Original location of the field = " &tLocold
put tLocold into tLoc
add 50 to item 1 of tLoc // Horizontal move
add 60 to item 2 of tLoc // // Vertical move
set the location of field ID tFieldID to tLoc
answer "New location of the field = " & tLoc
set the location of field ID tFieldID to tLocold
answer "Back to old location :-)"
end mouseUp
Re: How to move input fields covered by virtual keyboard
Posted: Thu Jun 21, 2018 5:45 pm
by jmburnod
Hi texter,
Some comments about your scripts
1. Using field "Field1" instead field Field1 (without quotes LC search a variable named Field1)
2. You may use id like this
put the short id of fld "Field1" into tFldID
put the short name of fld id tFldID into fld id tFldID -- tFldID = the id of fld "Field1"
3. Rect should be better than loc to be sure that the top of your fld > 0 (Same comment for mrcoollion)
4. In this case i would use a customproperty like uMyrectWithoutKB of fld "Field1" instead tLocold (tLocold is a local variable ?)
Good luck for next step
Jean-Marc
Re: How to move input fields covered by virtual keyboard
Posted: Fri Jun 22, 2018 12:50 pm
by Texter
Hi
Thanks Jean-Marc and mrcoollion The movement works now as I want.
But now I have the next trouble and do not know how to start.
On my card are six fields. If I want to fill in something in the upper 3 it is no problem.
The lower 3 fields I move to a location where the kexboard do not cover them. No problem now.
But the moved field lays under one of the upper fields and Labels.
Is this a problem with the layers?
How can I put them to the top? Or even better if I could underlay the field with a rectangle.
Texter
Re: How to move input fields covered by virtual keyboard
Posted: Fri Jun 22, 2018 1:01 pm
by Klaus
Hi Texter,
add this line before you actually MOVE your field u for text entry:
Code: Select all
...
### Will put the field on top of all other controls on the card!
set the LAYER of fld ID tFieldID to TOP
set the location of field ID tFieldID to tLoc
...
Best
Klaus
Re: How to move input fields covered by virtual keyboard
Posted: Tue Jun 26, 2018 7:10 pm
by Texter
Hi
I done it, thanks.
I move the field and the layer is on top but how can I exit the field when I entered some text?
Because if I do not exit the field the soft keyboard is still active and cover the next field where I want to fill in some text.
Texter
Re: How to move input fields covered by virtual keyboard
Posted: Wed Jun 27, 2018 7:24 am
by mrcoollion
Maybe this is an idea?
Make an additional button that only shows when the field is in enter data mode on the right side of the field with Ok label or an icon.
The action of this button is to move everything back to it's original position and layer, put the focus on something else and anything else you want to do (e.g. save data ...) and then hide it's self..
Regards,
Paul
Re: How to move input fields covered by virtual keyboard
Posted: Wed Jun 27, 2018 8:28 am
by Klaus
Yep, what Paul said!
Use something like this for your "OK" button:
Code: Select all
on mouseup
focus on nothing
end mouseup
Will surely make the keyboard disappear!
Re: How to move input fields covered by virtual keyboard
Posted: Wed Jun 27, 2018 9:08 am
by Texter
Hi
Thanks Paul, Klaus
Work fine now
Re: How to move input fields covered by virtual keyboard
Posted: Wed Jun 27, 2018 4:17 pm
by jacque
On mobile the usual way is to tap outside the field which will dismiss the keyboard. When the keyboard goes away, LC will send a keyboardDeactivated message. Trap that and have the handler move the field back down.
You will also get a keyboardActivated message when the field is tapped and the keyboard appears which you can use to move the field up.