question on togglebutton state retrieval
#1
Question 
hi,
could one help me find out how to conditionally run a different script pls?

I have a togglebutton so far, and depending on it's state a different script (or same script but other paramvalue) should be run.

I have a togglebutton defined as this:

Code:
<control type="togglebutton" id="90">
        <description>Toggle</description>
        <left>300</left>
        <top>25</top>
        <width>140</width>
        <height>55</height>

        <texturefocus>custom_homy_bizli_off.png</texturefocus>
        <texturenofocus>custom_homy_bizli_off.png</texturenofocus>
        <alttexturefocus>custom_homy_bizli_on.png</alttexturefocus>
        <alttexturenofocus>custom_homy_bizli_on.png</alttexturenofocus>

        <label>-</label>
        <onleft>1</onleft>
        <onright>1</onright>
        <onup>1</onup>
        <ondown>1</ondown>
</control>

and later on a button with an
Code:
<onclick>RunScript("/path/to/script/stateOn.py")</onclick>


I have no idea so far how to make it conditionally call a different script. Can one help me and give a hint? I don't find function like Control.GetState(90) or the like.

Thx in advance!
thomas[/code]

... and for the special ones... I did really search a very reasonable time on a solution. Once I know the solution I'm sure I'll find tons of resources and articles... but if you're on the wrong track and search on the wrong track you find the wrong stuff.
Reply
#2
Code:
<onclick condition="YOUR_CONDITION">RunScript("/path/to/script/stateOn.py")</onclick>
Reply
#3
alright, that makes totally sense of course - thx for this quick reply! But what I still don't get/find is how to access the state of a togglebutton. It should be something like (pseudo code):

Code:
<onclick condition="Control.isState(90)">RunScript("/path/to/script/stateOn.py")</onclick>
<onclick condition="NOT Control.isState(90)">RunScript("/path/to/script/stateOff.py")</onclick>

... or how to form the condition of the togglebutton and depending on that, call either ScriptA or ScriptB?
Reply
#4
You can simply add your own condition in the same way.

Try this -

Code:
<onclick condition="!Skin.HasSetting(stateOff)">RunScript("/path/to/script/stateOn.py")</onclick>
<onclick condition="!Skin.HasSetting(stateOff)">Skin.ToggleSetting(stateOff)</onclick>
<onclick condition="Skin.HasSetting(stateOff)">RunScript("/path/to/script/stateOff.py")</onclick>
<onclick condition="Skin.HasSetting(stateOff)">Skin.ToggleSetting(stateOff)</onclick>
Reply
#5
Thumbs Up 
Nod
thank you soooo much for you help, Hitcher. Now I got the logic and could easily make it work. You're the best!
Reply

Logout Mark Read Team Forum Stats Members Help
question on togglebutton state retrieval0