#TCL Radio Buttons
3 messages in this thread
I am just starting to use TCL and am very confused it seems. I have a window
on which I placed several RadioGroupPanes, each with 4 buttons. The original
code is generated by AppMaker 1.5.4. I am trying to get/set the initial values
of the radio buttons, but it ain't working.
One of the radio groups is created by AM as:
Group5 = new CRadioGroupPane;
Group5->IViewRes ('Pane', 133, enclosure, supervisor);
R5Radio = new CAMRadioControl;
R5Radio->IViewRes ('CtlP', 148, Group5, Group5);
JG5Radio = new CAMRadioControl;
JG5Radio->IViewRes ('CtlP', 149, Group5, Group5);
N5Radio = new CAMRadioControl;
N5Radio->IViewRes ('CtlP', 147, Group5, Group5);
L5Radio = new CAMRadioControl;
L5Radio->IViewRes ('CtlP', 177, Group5, Group5);
I then wrote the start of an initialization function with some testing in it to
see if I was approaching it right (I'm not) as:
/*———-*/
void CRinger::IRingerRadio (void)
{
long id;
id = Group5->GetStationID ();
Group5->SetStationID (147);
id = Group5->GetStationID ();
} /* IRingerRadio */
When I do the initial query, I get back a value of 0, which indicates that
nothing is selected. However, visually I can see that one radio is on, which
should mean that it is already selected?
I tried various inputs to the SetStationID, but it looked like I had to use the
same resource number that was used in the IViewRes call. It doesn't seem
reasonable that I would be expected to hard code those numbers in my stuff, but
I went ahead for this quick test. No dice — after the call, no radio is
highlighted — it even turns off the one that was on before (which at least
tells me I have hit the proper radio group).
The next call to GetStationID again returns 0, indicating that nothing is set.
At least that now agrees with the visual display…
What am I supposed to pass to these two calls to properly query/set the radio
buttons within a specified radio group?
– Burt
Burt,
There are at least two different ways to manage radio buttons in the TCL.
Get/SetStationID is one of the ways. (Setting a button to ON and letting
ProviderChanged turn off the other buttons is the other way.) Unfortunately, as
you have discovered, the ID field of a pane is initialized to 0. To use station
IDs you'll have to set the ID field of the radio groups to some unique number.
You could use the resource IDs as unique numbers. In your case, you could use
'R', 'J', 'N', and 'L'. (There isn't a method for setting the ID; you have to
assign directly to the instance variable.)
In AppMaker 1.5.4X (which I recommend you install) we generate code to set the
radio buttons' IDs to 1,2,3,4, etc. and generate Get/SetGroupChoice methods.
Spec
>> In AppMaker 1.5.4X (which I recommend you install) we generate code to set
the radio buttons' IDs to 1,2,3,4, etc. and generate Get/SetGroupChoice
methods.
That does sound much better! I'll go grab the updater and try it.
I saw the rather roundabout way that Rick set the IDs in his book, but just
figurered that _had_ to be a better way, which is what I was searching for.
Looks like your X version may be that simpler way. 🙂
– Burt