Radiobuttons

A radiobuttons item is used to place a set of radio buttons on the rollout, only one of which can be checked at a time. The user can click different buttons in the set to change states.

The syntax is:

radiobuttons <name> [ <caption> ] labels:<array_of_strings> [default:<number>] [columns:<number>]

The default alignment of radiobuttons items is #center.

Example:

radiobuttons copy_type labels:#("copy", "instance", "reference")

radiobuttons which_obj labels:obj_name_array -- computed label array

on copy_type changed state do ...

...

copyfn = case copy_type.state of

(

1: copy

2: instance

3: reference

)

...

Parameters

labels:

An array of strings that specifies the number of radio buttons and the text label for each one.

default:

The number of the radio button initially selected. Default is 1.

When set to 0, none of the radio buttons will be selected.

columns:

Number of columns across in which to arrange the buttons. By default, MAXScript will attempt to lay out all the radio buttons side-by-side on one line, and if they won't fit, vertically in a single column. You can force the layout system to array the buttons in multiple columns using this parameter. Each column is given the same width, which is the width of the widest label in all columns and it left-adjusts the radio buttons in these columns.

Properties

<radiobuttons>.state Integer

The number of the currently selected radio button in the order specified in the labels: array, or 0 if none is selected.

Example:

utility testRadioButtons "Test RadioButtons"

(

-- Define 2 radio buttons with the first button selected

radiobuttons radButtons labels:#( "First","Second") default:1

-- When the button is pressed, clear the radio buttons selection!

button setToNone "Clear Buttons Selection"

on setToNone pressed do radButtons.state = 0

)

 

Events

on <radiobuttons> changed <arg> do <expr>

Called when the user clicks one of the radio buttons in the set. The <arg> argument will contain the new state of the radio buttons array, which is the 1-based number of the newly selected button.

See also

Rollout User-Interface Items Common Properties

Rollout User-Interface Items Common Layout Parameters

Rollout User-Interface Control Types