Game Development Community

Can I set a "default selected" item in a GUIRadioButton object set?

by Ignis · in Game Design and Creative Issues · 06/28/2010 (6:30 pm) · 1 replies

Hello all,

(Note: I am using Torque Game Builder, but this issue seems relevant to TorqueScript in general and thus other Torque engines.)

My basic task is as follows: I have a simple set of radio buttons in a GUI (ButtonType = RadioButton). These are bitmap buttons that the player uses to select a certain option during gameplay. Only one option can be selected at a given time, which is why I used radio buttons. This basic premise does work and the buttons function as I want them to. However I also want to set one of these radio buttons as "on/selected/checked" when the level begins. This is where I run into a problem... I can't locate the option or setting to set this button in the "pressed" state upon level load.

I did come across the
setStateOn(bool bStateOn)
function, but I'm unsure how to use this. What are the possible options for "bStateOn" ? This might also be the completely wrong function for this purpose; it seems to me that setting a "state" is more geared toward setting a bitmap button's state (default, depressed, highlighted, inactive), and my intention is more toward saying that the particular radio button is selected.

I also came across the
setValue(arg)
function, and it appears that "arg" can be a rather unspecific parameter which depends on the type of GUI control it's referring to, and I can't locate a definitive list of arguments for the various GUI controls.

Anyway, I hope somebody has some insight into this. As always, thanks in advance!

Brent

#1
06/28/2010 (6:39 pm)
ARGH! Minutes after posting this, I discovered the solution:

ThisRadioButton.performClick();

This "simulates a mouse click" which does exactly what I needed; I just didn't notice the function earlier. Well, hopefully this post can be of some use to other programmers down the road...