Page 1 of 2

setting the focus with keyboard property on a field

Posted: Sat Jun 09, 2018 11:41 pm
by mvillion
Hi

I am trying to set the 'focus with keyboard' property of a field via a script but I cannot find out how.

It is available in the properties but I cannot find it in the dictionary for fields properties.

Any ideas people?

thanks
Matt

Re: setting the focus with keyboard property on a field

Posted: Sun Jun 10, 2018 1:20 am
by dunbarx
Hi.

Do you mean something like tabbing from one field to another? That action does indeed involve the keyboard.

Or you might use the "keyDown" or "rawKeyDown" messages (or their cousins) to send a message giving focus to the next field in the tabbing order (or any other field at all, for that matter)

Is that what you meant?

Craig Newman

Re: setting the focus with keyboard property on a field

Posted: Sun Jun 10, 2018 10:12 am
by mvillion
Ok.

Set up a stack.
Place a field
Look at the properties of a field. There is a property called 'focus with keyboard'.

This allows the keyboard to focus on the field so things can be typed into it (or not)
Sometimes I want to allow it. Other times I don't.

I want to toggle it via a script but I cannot find the 'property name' to be able to address it.


Thanks

Re: setting the focus with keyboard property on a field

Posted: Sun Jun 10, 2018 11:48 am
by jmburnod
Hi,
I want to toggle it via a script but I cannot find the 'property name' to be able to address it.
I think you look for traversalOn
Best regards
Jean-Marc

Re: setting the focus with keyboard property on a field

Posted: Sun Jun 10, 2018 3:44 pm
by richmond62

Code: Select all

on mouseUp
   focus on fld "ff1"
end mouseUp
fff.png
Focus.livecode.zip
(990 Bytes) Downloaded 320 times
OK, OK: that's with a mouseClick rather than a keyboard initiator . . .

Code: Select all

on keyDown KD
if KD = "q" then
focus on fld "ff1"
end if
end keyDown

Re: setting the focus with keyboard property on a field

Posted: Sun Jun 10, 2018 4:22 pm
by Klaus
Hi Matt,

good advice: Open the LC preferences, on the "General" part check -> Property Labels are -> Name of LiveCode properties

Now the inspector will show the names of the properties as used for scripting instead of their "human readable" expalantion.


Best

Klaus

Re: setting the focus with keyboard property on a field

Posted: Sun Jun 10, 2018 4:48 pm
by jacque
One of the first things I tell new users is to do what Klaus suggested. Regardless of which setting you use though, hovering over the label will show a tooltip that gives you the alternate information.

Re: setting the focus with keyboard property on a field

Posted: Sun Jun 10, 2018 11:26 pm
by dunbarx
Oh, You really meant "focus with keyboard".

Why didn't you say so? :wink:

It has been so long since I ever used the "human readable" labels that I never made the connection.

Craig

Re: setting the focus with keyboard property on a field

Posted: Sun Jun 10, 2018 11:40 pm
by mvillion
Wow.

I feel like a complete NOOB.

Hover over label to get the value. Doh!

Many thanks

Re: setting the focus with keyboard property on a field

Posted: Mon Jun 11, 2018 3:14 am
by bogs
mvillion wrote:
Sun Jun 10, 2018 11:40 pm
Wow. I feel like a complete NOOB.
Exhilarating isn't it? I feel that way every 3rd or 4th time I start a project... :D

Re: setting the focus with keyboard property on a field

Posted: Mon Jun 11, 2018 5:31 am
by jacque
bogs wrote:
Mon Jun 11, 2018 3:14 am
mvillion wrote:
Sun Jun 10, 2018 11:40 pm
Wow. I feel like a complete NOOB.
Exhilarating isn't it? I feel that way every 3rd or 4th time I start a project... :D
LOL. You would not believe the dumb thing I did last night. Two hours debugging something that wasn't even broken because I overlooked the obvious. Twice.

Re: setting the focus with keyboard property on a field

Posted: Mon Jun 11, 2018 7:38 am
by richmond62
I feel like a complete NOOB.
Continuously since my first contact with HyperCard in 1993. 8)

Re: setting the focus with keyboard property on a field

Posted: Mon Jun 11, 2018 2:58 pm
by dunbarx
Continuously since my first contact with HC in 1987.

Craig

Re: setting the focus with keyboard property on a field

Posted: Mon Jun 11, 2018 3:27 pm
by bogs
At least we're in good company eh, mvillion :wink:

Re: setting the focus with keyboard property on a field

Posted: Sun Feb 16, 2020 11:58 am
by RobertC
I just had exactly mvillion's question.

I'm appalled at the number of answers that simply do not address the very clearly stated question: how does one set the focus with keyboard from a script? For example, dunbarx obviously can't read that, but he is not the only one. This sort of well-meaning, fast response that is completely off the mark is very typical of programming forums. Stack Overflow is full of them, so are all the others and this one is no exception. Sigh. (nothing against dunbarx in particular, he just happened to be the first one encountered, sorry that you happen to function as my example)

As jmburnod answered, it's not possible to set focus with keyboard because the property is actually called traversalon. Thanks Jean-Marc.
I too have set the LiveCode preference to show property labels as name of property, not description of option. But that seemingly does not work: the property inspector still gives wrong information.

The IDE is so full of small bugs that I despair. I've been using Hypercard from 1985, until I discovered runrev in 2000 and have been a LiveCode/RuntimeRevolution user ever since. I would not know what to do without LiveCode.
But I sincerely hope that instead of rushing into the next feature development, the LiveCode team will take a year or so to fix the literally hundreds of annoying small bugs that make development highly irritating. Any first-time user trying out LiveCode will hit these problems, finally give up, and never come back.

The solution to mvillion's problem is indeed to set traversalon to true/false

Bye guys, have a nice day.