Page 1 of 1

Changing Properties with script

Posted: Mon Jan 27, 2014 9:52 pm
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

Re: Changing Properties with script

Posted: Mon Jan 27, 2014 10:13 pm
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

Re: Changing Properties with script

Posted: Mon Jan 27, 2014 10:18 pm
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.

Re: Changing Properties with script

Posted: Mon Jan 27, 2014 10:22 pm
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

Re: Changing Properties with script

Posted: Mon Jan 27, 2014 10:23 pm
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)

Re: Changing Properties with script

Posted: Mon Jan 27, 2014 11:57 pm
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

Re: Changing Properties with script

Posted: Tue Jan 28, 2014 12:07 am
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

Re: Changing Properties with script

Posted: Tue Jan 28, 2014 12:14 am
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

Re: Changing Properties with script

Posted: Tue Jan 28, 2014 12:38 am
by dave.kilroy
Yay! Sounds good ... what are you building?

Re: Changing Properties with script

Posted: Tue Jan 28, 2014 4:46 pm
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.