PDA

View Full Version : Change my value from an another field



stany
July 20th, 2017, 08:51
Hello everyone,
from my field A, I know change an another value (B for example) when the Field's value A change with "OnValueChanged".
But I try to do the opposite : from my value A, I want that this value change when an another value change (I don't want use "OnValueChanged" on this another field.)
Is there a function like 'OnSourceChanged" ?
I see in 3.5 template_char some templates with "<source>...</source><op>+</op>".Is the good way ?
Thanks for your help.

Trenloe
July 20th, 2017, 13:46
Is there a function like 'OnSourceChanged" ?
Yes, but you need to create the event handler for onValueChanged on the FG control you want, using the GUI hierarchy, e.g. if your control is called "mydatafield" then you can access that in the current window with window.mydatafield and then write a handler function look at onValueChanged on that control, e.g. window.mydatafield.onValueChanged = myCustomOnValueChangedFunction

See "Handler Functions" at the bottom of this page here: https://www.fantasygrounds.com/modguide/scripting.xcp The example given is creating a sourceUpdate function for a different database node.


I see in 3.5 template_char some templates with "<source>...</source><op>+</op>".Is the good way ?
This will add the contents of the <source> database node together with other <source> database nodes. Or, if there is just one <source> entry, it will essentially link the field directly to that database node. So, if you want to add (or subtract) data from database fields or link to a single database field, then this is a good way to go.

stany
July 22nd, 2017, 13:51
Hello,
thanks for your help !