Changing Properties with script

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Changing Properties with script

Post by DavJans »

Im trying to make a field Un-Focusable if a previous field has No in it is

Code: Select all

if fld "cats" = "No" then
set fld "#ofcats" unfocusable
I hope my question makes sense.

even better if you can point me at a lesson on manipulating properties
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2734
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Changing Properties with script

Post by jmburnod »

Hi DavJans,

Try this:

Code: Select all

if fld "cats" = "No" then
 set the traversalon of fld "cats" to false
end if
Best regards
https://alternatic.ch
DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Re: Changing Properties with script

Post by DavJans »

Thank you, I was just coming back here to I found the lesson on this.
I would post the url as reply to my own question for others if they have the same question, but not allowed unless a moderator does it.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: Changing Properties with script

Post by dunbarx »

Hi.

What Jean-Marc said.

You will get a slightly different behavior if the locktext of the field is either true or false. Try both, and see which fits your expectations better. If "false" you can select the text but not do anything with it, if "true" you are locked out completely.

Craig Newman
dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Changing Properties with script

Post by dave.kilroy »

Hi DavJans

Apart from traversalOn the other thing I find makes a difference is whether the field has autoHilite set to true (this makes the forbidding and allowing of access via the traversalOn setting more obvious)
"...this is not the code you are looking for..."
DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Re: Changing Properties with script

Post by DavJans »

Code: Select all

 set the traversalon of fld "cats" to false
end if
worked great thank you.

this however

Code: Select all

on openField
set the traversalon to fld "cats" to true
end openField
does not work, or at the very least its not working for me
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Changing Properties with script

Post by dave.kilroy »

DavJans wrote:

Code: Select all

 set the traversalon of fld "cats" to false
[code]
set the traversalon to fld "cats" to true
Your first line of code uses "of fld..." but your second line uses "to fld..."

Also, putting that code in the field's openField handler is, in my opinion, asking for trouble because you are making use of an event (openField) in which to forbid the event that has just fired! Try putting your code in the field's exitField handler or similar
"...this is not the code you are looking for..."
DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Re: Changing Properties with script

Post by DavJans »

that was a typo sorry, and the code is not in the script of the field I just set to traversalon to false, that would be silly. I would post my project but its my first ever, and very messy. I got around that issue by putting it in the "3rd" fields closeField Handle
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Changing Properties with script

Post by dave.kilroy »

Yay! Sounds good ... what are you building?
"...this is not the code you are looking for..."
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Changing Properties with script

Post by jacque »

The most common way to disallow field entries in these situations is to set the enabled of the field to false. That handles both the ability to focus or make text entries as well as visually changing the appearance so the user knows it isn't a valid control.

Since you're using it as a response to a checkbox, do it when the hilite of the button changes.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
Post Reply