Detection of Keyboard Closing

J. Landman Gay jacque at
Wed Mar 14 16:03:56 EDT 2012

On 3/14/12 2:09 PM, Michael Doub wrote:
> Is there a way to detect that the user has closed the keyboard on
> Android?
> Maybe someone can point out an appropriate technique to solve my
> problem.  I have a card with one editable field on it.  When I go to
> that card currently the focus immediately go to that field and the
> keyboard pops up.   I would like the field to remain editable, but
> only if it is selected by the user.  I would like to be notified upon
> completion.

It's an ancient problem that dates back to the origins of the engine. 
The first object with traversalOn will get the focus. On Windows, where 
buttons can be focused, the solution is to set a button to a lower layer 
than the first field. On Mac, and apparently mobile (I haven't checked,) 
that doesn't work.

One workaround is to add a short handler that removes the focus and send 
it from a preOpenCard. It doesn't trigger right if you just add "focus 
on nothing" to a pre- or openCard handler.

on preOpenCard
   send "noSelect" to me in 1
end preOpenCard

on noSelect
   focus on nothing
end noSelect

I haven't tried this on mobile yet, but that's how I do it in desktop 
apps. On mobile the keyboard might pop up and disappear if the timing 
isn't right. Let us know.

Another way to handle it is to set the field's traversalOn to false in 
preOpenCard and then set it back to true on openCard. I've had mixed 
results with that method, but you can try it:

on preOpenCard
    set the traversalOn of fld 1 to false
end preOpenCard

on openCard
    set the traversalOn of fld 1 to true
end openCard

Jacqueline Landman Gay         |     jacque at
HyperActive Software           |

More information about the Use-livecode mailing list