PDA

View Full Version : GUI - radiobutton


Pablo Concha
03-25-2008, 07:43 AM
Hello,

-i'm trying to use radiobuttons on a gui, i'm using onPress attibute to change a variable and it works, but visually the radiobuttons don't save the state when closing/open the window. How does this works?..

regards,

Pablo Concha E.

tobias.biemueller
03-25-2008, 08:03 AM
Hello Pablo,

i dont know it exactly, but i found a Thread with nearby the same theme.. (checkbox instead of radiobutton). maybe it helps you a little bit..

http://www.flexsim.com/community/forum/showthread.php?t=312

Tobias

Pablo Concha
03-25-2008, 08:19 AM
Thanks Tobias, i read that post before, tried an example and didn't work... i think i did something wrong, becouse now i tried it again and it did work :rolleyes:.

thanks,

Pablo Concha E.

Brandon Peterson
03-26-2008, 09:30 AM
Pablo,

From my experience you will need to manually check/select the radio button that you want selected when the GUI opens, this applys to check boxes as well. To do this use the OnOpen node in the main GUI node.

The Object Properties GUI uses the following code to set whether or not a check box is checked:

setchecked(node("/Show Name",settingspanel), not(switch_hidelabel( focus)));


The Separator Tab in the Separator's Parameters GUI uses the following code to set the appropriate radio button as selected (Unpack is selected by default):


if(not(getnodenum(node("@>objectfocus+>variables/unpack",c))))
setchecked(node("../Split",c), 1);

As a general rule of thumb "if its been done before then steal it." To steal part of a GUI right click on the GUI you wish to pirate from and select view -> Explore structure. This will open up a tree view of the GUI and you can copy the code and nodes you will need from there.


Good Luck,
Brandon
Flexsim GUI Pirate / Consultant

Eike Schulz
07-03-2011, 04:08 AM
Thanks for your Tip Brandon,

but how do i correctly reference a radiobutton? I have three radio-buttons that control a global variable. Your on open check works fine and the specific case is executed corresponding to the global variable but the corresponding button is not checked. I tried to reference it via node ranks like this:

setchecked(node("../2/2/1",c), 1);

but obiously this does not work.
Can you tell me a better (i.e. a working one :() way to reference?

Thanks a lot

Eike Schulz

Eike Schulz
07-03-2011, 07:08 AM
Found the solution on my own via "pathtonode()" after some brain crunching. Got confused before because the path differs depending on if you are editing the GUI or using it :rolleyes:.
--> When editing it the path is "Main:1/..."
--> When using it it obiously starts with "View: ..."

Now it works fine so thanks again for the idea Brandon!

Jason Lightfoot
07-03-2011, 01:13 PM
What you'll find is that it's 'c' that changes (sometimes it's the node itself, but it can also be the viewcontrol or the object that contains it)- and that depends how the node is called (it's specified by executefsnode)

If you're not sure for a given node, you can print out the path for c, or to reference the root of the active GUI you can always use node("@",c) and avoid the need to find the full path.