Page 1 of 1
Focus command question
Posted: Sat Feb 23, 2019 9:35 pm
by Pistris
Hi guys
am having a problem where i have a card that has a field and everytime
that i call that card the keyboard shows up cause it focuses on the field
i have tried using FOCUS ON NOTHING on several parts of my code but
no luck with it
The only way i found to prevent this from happening is disabling it and
the enabling it if i click on it but its not a clean way to do this as i have to make sure
to disable every field
any suggestions?
thanks
Re: Focus command question
Posted: Sun Feb 24, 2019 12:00 am
by richmond62
the keyboard shows up
Presumably by this you mean that you are programming for Android or iOS.
The best way to stop focussing in fields is to fiddle around in the properties palette
of the field:
-
Re: Focus command question
Posted: Sun Feb 24, 2019 1:04 am
by Pistris
Yes already played with those settings
once the card is loaded it will focus on the field regardless
the only way I can make it not focus on it is by disabling it
but that is not what I want to do
Re: Focus command question
Posted: Sun Feb 24, 2019 2:19 am
by [-hh]
For me this works:
If the locktext of a field is true then it doesn't trigger the keyboard.
Re: Focus command question
Posted: Sun Feb 24, 2019 1:28 pm
by bogs
If that doesn't work for you, perhaps some variation of one of the following from
this thread will - transversal for instance is mentioned.
Pistris wrote: ↑Sat Feb 23, 2019 9:35 pm
The only way i found to prevent this from happening is disabling it and
the enabling it if i click on it but its not a clean way to do this as i have to make sure
to disable every field
I'm not sure why this would not be a clean way to do it, something like (psuedo code) -
Code: Select all
on openCard
repeat with x=1 to the number of controls of this card
if word 1 of the name of control x is "field" then set the disabled of control x to "true"
end repeat
end openCard
on mouseUp (or whatever handler you need to activate the field)
set the disabled of the target to "false"
end mouseUp
but then, I do no mobile programming, so maybe it is taboo somehow.
Re: Focus command question
Posted: Sun Feb 24, 2019 5:17 pm
by jacque
It's a universal "feature" on all OSs, the first control with traversalOn will get the focus. If it's a field, it gets the insertion point, if it's a button (which can be focused on Windows) it gets the selection outline. On mobile, any field with focus also triggers the keyboard.
Setting the focus is one of the last things LC does after opencard, so you can't trap the behavior directly from any open* message. But you can send a message in time to deal with it. The culprit is traversalOn, and the general idea is:
Code: Select all
on preOpenCard
tvsOn false
send "tvsOn true" to me in 1 millisecond
end preOpenCard
on tvsOn pBool
set the traversalOn of fld 1 to pBool
end tvsOn
Since LC will focus on the first control with traversalOn, you may have to include more than one field in the tvsOn handler.
Re: Focus command question
Posted: Tue Feb 26, 2019 10:44 pm
by Pistris
@jacque Thank you very much
this worked like a charm
@ Bogs, thank you man that also works, but (at least on my phone) when
i try it, it displays the keyboard for a brief moment
when I try it on the simulator the keyboard does not show.
but thanks for taking the time to answer
Re: Focus command question
Posted: Tue Feb 26, 2019 11:38 pm
by bogs
Sharing knowledge makes us all better, but I am glad Jacque answered with the 'why' and not just the 'how'
