Focus command question
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Focus command question
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
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
-
- Livecode Opensource Backer
- Posts: 9285
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Focus command question
Presumably by this you mean that you are programming for Android or iOS.the keyboard shows up
The best way to stop focussing in fields is to fiddle around in the properties palette
of the field:
-
Re: Focus command question
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
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
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Focus command question
For me this works:
If the locktext of a field is true then it doesn't trigger the keyboard.
If the locktext of a field is true then it doesn't trigger the keyboard.
shiftLock happens
Re: Focus command question
If that doesn't work for you, perhaps some variation of one of the following from this thread will - transversal for instance is mentioned.
but then, I do no mobile programming, so maybe it is taboo somehow.
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
-
- VIP Livecode Opensource Backer
- Posts: 7214
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Focus command question
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:
Since LC will focus on the first control with traversalOn, you may have to include more than one field in the tvsOn handler.
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
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Focus command question
@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
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
Sharing knowledge makes us all better, but I am glad Jacque answered with the 'why' and not just the 'how'