Radiobuttons UI Controls
 
 
 

User Interface Controls > Common Properties > Layout > Types > Radiobuttons

 

   

Creating User Interfaces - Quick Navigation

A radiobuttons control 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> [tooltip:{<string>|<array_of_strings>}] [default:<number>] [columns:<number>] 	 

The default alignment of radiobuttons items is #center.

EXAMPLE:

--Create some scene objects. Select them, then run the script:
(
local obj_array = selection as array
local obj_name_array = for o inobj_arraycollect o.name
rollout CloneObject "Clone Object" (
radiobuttons copy_type labels:#("copy", "instance", "reference")
radiobuttons which_obj labels:obj_name_array -- computed label array
button do_it "Copy Object"
fn updateButton = (
do_it.text = case copy_type.state of (
1: "Copy "
2: "Instance "
3: "Reference ")
do_it.text += obj_name_array [which_obj.state]
)--end fn
on copy_type changed state do updateButton()
on which_obj changed state do updateButton()
on CloneObject open do updateButton()
on do_it pressed do (
copy fn =case copy_type.state of (
1: copy
2: instance
3: reference)
if which_obj.state > 0 do copyfn obj_array[which_obj.state]
)--end on pressed
)--end rollout
if obj_array.count > 0 do createDialog CloneObject
)--end script
 

   

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.

EXAMPLE:

--create radio buttons with two columns:
rollout testRollout "Test Size"
(
radiobuttons rad_buttons "Size:" labels:#("Big", "Bigger", "Biggest", "Huge") columns:2
)
createDialog testRollout

   

tooltip: { <string>|<array_of_strings>}

NEW in 3ds Max 2012: Provides tooltip or tooltips for the radio buttons.

If string is specified, that string is used as tooltips for all radiobuttons.

If an array of strings is specified, the array size must be the same as the labels array size and the corresponding array element is used for each radiobutton.

EXAMPLE:

rollout MyRollout "Untitled" width:162 height:300 
(
radioButtons rdo1 "RadioButtons" tooltip:"Test Tooltip 1" labels:#("Button1", "Button2") 
radioButtons rdo2 "RadioButtons" tooltip:#("Test Tooltip 2","Test Tooltip 3") labels:#("Button1", "Button2") 
radioButtons rdo3 "RadioButtons" labels:#("Button1", "Button2") 
-- radioButtons rdo4 "RadioButtons" tooltip:#("Test Tooltip 4") labels:#("Button1", "Button2") 
button btn1 "Button" tooltip:"Test Tooltip 5" 
) 
createdialog MyRollout

--Enabling the remarked rdo4 will cause
--an error because the number of tooltip items
--does not match the number of labels items

Example script:

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:

rollout 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
)
createDialog testRadioButtons

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.

   

on <radiobuttons> rightClick do <expr> 

Called when the user right-clicks the Radiobuttons control.

Available in 3ds Max 2010 and higher.

   

See Also