2010

Table Of Contents
The first element of the array, the roll_Cube, is selected.
Elements of an array are accessed using square brackets containing the
index number of the element you want to extract from the array. The
index number of arrays start counting from zero.
2 Add the following commands to the top of your user interface script in
the MEL2 tab:
$all_selected_objects=`ls -selection`;
$first_selected_object=$all_selected_objects[0];
select $first_selected_object;
These commands change your selection to the object you selected first.
3 In the MEL2 tab, change the argument of the text flag located on line
14 of the original script (you can use the MEL tab for reference) from
name_of_object to the following:
$first_selected_object
The command now reads:
$obj_name_text = `textField -editable 0 -width 400 -text
$first_selected_object`;
The text field now displays the currently selected object.
If you attempt to execute the modified user interface creation script
without an object selected, an error occurs, as no elements exist in the
string array $all_selected_objects.
TIP Dont execute the script from the MEL2 tab yet, as it will clear the tab
and we want to continue modifying the script. If you do want to execute the
script at any interim time, create a new MEL tab, copy the script into it, and
execute that.
Linking the check boxes
Check boxes can also use command flags, similar to a button. A check box
has more functionality than a button, so the command flags are different.
Check boxes have three possible command flags; changeCommand, onCommand,
and offCommand:
The changeCommand flag triggers whenever the state of the check box
changes.
The onCommand flag triggers when the check box is checked.
Linking the user interface | 697