radiobuttons コントロールは、一連のラジオ ボタンをロールアウトに配置するのに使用します。一度に 1 つしかチェックできません。ユーザはセット内のさまざまなボタンをクリックして状態を変えることができます。
構文は次のようになります。
radiobuttons <name> [<caption>] labels:<array_of_strings> [tooltip:{<string>|<array_of_strings>}] [default:<number>] [columns:<number>]
radiobuttons
項目の既定の位置合わせは、
#center
です。
例:
|
--シーン オブジェクトをいくつか作成し、選択してスクリプトを実行:
(
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 -- 計算されたラベル配列
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]
)-- 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]
)--on pressed 終了
)-- ロールアウト終了
if obj_array.count > 0 do createDialog CloneObject
)-- スクリプト終了
|
|
パラメータ
ラジオ ボタンの数と各ラジオ ボタンのテキスト ラベルを指定する文字列配列です。
最初に選択されているラジオ ボタンの番号です。既定値は 1 です。
0 に設定すると、ラジオ ボタンはまったく選択されません。
ボタンを配置する列の数です。既定では、MAXScript はすべてのラジオ ボタンを 1 行に並べてレイアウトしようとします。1 行に入りきらない場合には、1 列下げます。このパラメータを使用すると、複数の列にボタンを配列するレイアウトにするように強制できます。各列には同じ幅が与えらます。この幅はすべての列の最大ラベルの幅であり、列内のラジオ
ボタンは左揃えになります。
例:
|
--ラジオ ボタンを 2 列で作成
rollout testRollout "Test Size"
(
radiobuttons rad_buttons "Size:" labels:#("Big", "Bigger", "Biggest", "Huge") columns:2
)
createDialog testRollout
|
tooltip: { <string>|<array_of_strings>}
3ds Max 2012 の新機能: ラジオ ボタンのツールチップまたはツール ヒントを提供します。
文字列を指定すると、その文字列がすべてのラジオ ボタンのツールチップとして使用されます。
文字列の配列を指定する場合、配列のサイズはラベルの配列サイズと同じにする必要があり、対応する配列要素が各ラジオ ボタンに使用されます。
例:
|
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
-- 上記の rdo4 を有効にすると -- ツールヒント項目の数がラベル -- 項目の数と一致しないため、エラーになる
|
スクリプト例:
プロパティ:
<radiobuttons>.state Integer
この番号は
labels:
配列で指定されている順番になります。何も選択されていない場合は、0 になります。
例:
|
rollout testRadioButtons "Test RadioButtons"
(
-- 最初のボタンが選択されている 2 つのラジオ ボタンを定義
radiobuttons radButtons labels:#("First","Second") default:1
-- ボタンを押したときに、ラジオ ボタンの選択が解除!
button setToNone "Clear Buttons Selection"
on setToNone pressed do radButtons.state = 0
)
createDialog testRadioButtons
|
イベント
on <radiobuttons> changed <arg> do <expr>
セット内のラジオ ボタンの 1 つをクリックすると呼び出されます。
<arg>
引数には、ラジオ ボタン配列の新しい状態が入ります。新たに選択されたボタンの番号は 1 から始まります。
on <radiobuttons> rightClick do <expr>
ユーザがラジオボタン コントロールを右クリックしたときに呼び出されます。
3ds Max 2010 以降で使用可能です。