Scripting a GuiRadioCtrl button
by Don Schaper · in Torque Game Builder · 06/12/2006 (10:33 pm) · 4 replies
I would like to add a couple GuiRadioCtrl button groups to an options dialogue. I've created the GUI and it works fine (by using a different groupNum for each group). Unfortunately, I don't know how to create the script to manipulate the darned things. TDN's GUI/Profiles/ControlList is silent on the usage of a GuiRadioCtrl. None of the TGB example games or tools use this button. The forums didn't provide any useful information.
It's probably dead-simple; but could someone clue me in on how to create the necessary script?
It's probably dead-simple; but could someone clue me in on how to create the necessary script?
#2
About a year and a half ago I worked with radio buttons in a TGE project, and you basically have to track the status of which button is currently pressed invidivually, because their isn't a "RadioButtonSet" that maintains this information for you.
Basically what the code does is very..well, basic: when you press a radio button, it will search for other buttons at that same level and make sure they aren't pressed--the problem is, there isn't a concept of querying which button is currently pressed, or a callback when a button is pressed.
Not the best implementation I know...just something to work around manually, and it isn't -too- difficult to do so.
06/22/2006 (11:19 am)
@Don: I agree, the stock radio buttons implementation (and this is stock-stock, as in core Torque technology, not just TGB) isn't implemented intuitively or very accurately.About a year and a half ago I worked with radio buttons in a TGE project, and you basically have to track the status of which button is currently pressed invidivually, because their isn't a "RadioButtonSet" that maintains this information for you.
Basically what the code does is very..well, basic: when you press a radio button, it will search for other buttons at that same level and make sure they aren't pressed--the problem is, there isn't a concept of querying which button is currently pressed, or a callback when a button is pressed.
Not the best implementation I know...just something to work around manually, and it isn't -too- difficult to do so.
#3
06/22/2006 (11:28 am)
Yeah the implementation works, but doesn't have quite the support you would want. What I usually end up doing is first make sure they have proper groupNum set (as you've seemed to figure out), if they are in the same groupNum they will ensure one of is triggered at a time. Then I put a single command in all of the ratio buttons of the same group that grabs the data and processes it.
#4
The solution I came up with certainly works. You set each group of radio buttons a different GroupNum; and then write script to deal with each individual button. My bad; for assuming that a more elegant solution had to exist.
06/22/2006 (1:58 pm)
Thank you, Stephen & Matthew, for responding. The solution I came up with certainly works. You set each group of radio buttons a different GroupNum; and then write script to deal with each individual button. My bad; for assuming that a more elegant solution had to exist.
Torque Owner Don Schaper
XIX Software
Again... I'm sure that the solution will seem so obvious that only a brain-dead coder could miss it.