-
November 18th, 2014, 11:17 #1
buttoncontrol/buttonfield getValue problem
Hi,
I don't know if there is some problem or I'm missing something about buttoncontrol/buttonfield controls, because I'm unable to retrieve the actual control value by the getValue function.
I have this code:
Code:<buttonfield name="showoptions"> <state icon="expand" /> <state icon="collapse" /> <anchored to="rightanchor" width="10" height="10"> <top offset="5"/> <right anchor="left" relation="relative" offset="-5" /> </anchored> <script> function onValueChanged() if getValue() == 0 then actions.setVisible(false); else actions.setVisible(true); end end </script> </buttonfield>
-
November 18th, 2014, 12:38 #2
can you do a setValue or some other action to make sure your onValueChanged is being read/actioned first?
-
November 18th, 2014, 17:18 #3
All the calls to the class own functions throw errors (getValue, setValue, setStateTooltipText), but the inherited functions (setVisible, setTooltipText) works.
-
November 18th, 2014, 20:44 #4
hmmm... dont you need to be specifying the button specifically?
function getValue( sourcenode, [subpath], [default] )
-
November 18th, 2014, 21:40 #5
This is for retrieving the value from database. It should be possible to get the value directly from the control.
-
November 20th, 2014, 22:38 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,548
Did you figure this out already?
If not,
* How is onValueChanged being called? (directly by FG when node value changes, or via external call)
* Are there any error messages in the console other than the missing getValue function?
* What do you get when you add a Debug.console(self) to the first line of the onValueChanged function?
Regards,
JPG
-
November 21st, 2014, 06:08 #7
Hi JPG,
- the onValueChange event is called directly by FG, when the button is pressed by the user.
- that is the only error in the console:
[21.11.2014 06:02:36] Script Error: [string "char_attribute:showoptions"]:1: attempt to call global 'getValue' (a nil value)
- the Debug.console(self) returns:
[21.11.2014 06:04:17] Script Notice: WINDOWCONTROL = { nil }
Regards
-
November 25th, 2014, 21:26 #8
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,548
It sounds like perhaps the onValueChanged event is being called in the middle of creation or destruction of the window. Any chance this could be happening? If so, you may have to add a flag to prevent the processing of the onValueChanged event code until after onInit event has been called, or prevent processing after onClose event has been called.
Otherwise, I'll probably have to take a look at the code directly on my machine to see what is going on.
Regards,
JPG
-
November 28th, 2014, 11:19 #9
-
November 30th, 2014, 00:41 #10
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,548
I have no idea. I'd have to run the code to see what is happening.
Do you have a copy of the ruleset somewhere that I can download and look at? As well as instructions to recreate?
Regards,
JPG
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks