Radio-button groups
A row-column widget containing several toggle-button widgets (CwToggleButton) can be configured to have radio-button behavior.

Radio-button group
When a button is selected in this mode, any other selected buttons in the group are automatically deselected, leaving only one button selected at any time. The radioBehavior resource of the CwRowColumn widget controls this behavior.
Create a CwRowColumn with radioBehaviour set to true using the convenience method createRadioBox:argBlock:.
As a side effect of createRadioBox:argBlock:, the CwRowColumn isHomogeneous resource is set to true. Children of a homogeneous row-column widget must all be of the same type. In this case, they must all be CwToggleButton widgets.
You can select or deselect a toggle button using the setState:notify: method. Its state can be queried using the getState method. The valueChanged callback of a toggle button is run whenever the state of the button changes.
The valueChanged callback is run when a button is deselected as well as when it is selected. The state of the widget should be checked in the callback using the getState method, or by checking the set field of the callback data.
In the following example, a radio-box row-column is created. Three toggle buttons are added. The same valueChanged callback is added to each toggle button, with the client data used to identify the selected button. The resulting radio-button group is shown in the left margin. For simplicity, the shell is not shown.
| shell rowColumn button buttonNames initialValues languageNames |
shell := CwTopLevelShell
createApplicationShell: 'shell'
argBlock: [:w | w title: 'Radio Box Example'].
rowColumn := shell
createRadioBox: 'radio'
argBlock: nil.
rowColumn manageChild.
buttonNames := #('Hello' 'Bonjour' 'Hola').
initialValues := (Array with: true with: false with: false).
languageNames := #('English' 'French' 'Spanish').
1 to: buttonNames size
do: [:i |
button := rowColumn
"The state of each toggle button is set on creation according
to the corresponding value in the initialValues array. In this
example, Hello is selected."
createToggleButton: (buttonNames at: i)
argBlock: [:w | w set:
(initialValues at: i)].
addCallback: XmNvalueChangedCallback
receiver: self
selector: #language:clientData:callData:
clientData: (languageNames at: i).
button manageChild].
shell realizeWidget.
The valueChanged callback used by the code is shown below. The selected language is indicated by the clientData argument. A message is written to the transcript whenever a new language is chosen.
language: widget clientData:clientData callData: callData
"A toggle button has changed state."
callData set
ifTrue: [Transcript cr; show: 'The selected language is now ',
clientData, '.'].
Last modified date: 12/21/2017