Page 1 of 1

Keyboard remains visible

Posted: Wed Mar 01, 2023 10:19 am
by GoneToSail
Good morning,
In a mobile app, I need that depending on the user profile, all fields of a given card are editable or not. In order to make these fields not editable when closing this card (and possibly allow modifications only when it will be reopened), I have included something like this in the closeCard script:

Code: Select all

repeat with i=1 to the number of fields of this cd
   set the lockText of fld i to true
   set the traversalOn of fld i to false
end repeat
I thought that this would be enough to hide the keyboard on closing the card. However I find that when some fields of this card have been edited and the user is going to another card (which does not include any editable field), the keyboard remains visible.
How is this possible, and how to obtain that the keyboard disappears when going to another card ?
Thanks for any assistance !

Re: Keyboard remains visible

Posted: Wed Mar 01, 2023 3:13 pm
by livecode-atc
Hi @GoneToSail , try putting focus on nothing after your repeat.
I don't know why it uses the closeCard but personally I like to use the preOpenCard and if you know the name of those fields that cannot be edited. The loop I would use would be something like:

Code: Select all

repeat for each item tFieldName in "field 1, field 2, ...." ---> The name of the fields separated by comma
   set the lockText of fld i to true
   set the traversalOn of fld i to false
end repeat

focus on nothing

Re: Keyboard remains visible

Posted: Wed Mar 01, 2023 3:32 pm
by GoneToSail
Thanks so much !
I did not know that command, and it works fine.
It seems also a good idea to move the "lock" script in preOpenCard.
Regards