Dropdownlist UI Control

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

 

   

Creating User Interfaces - Quick Navigation

A dropdownlist control is used to place a drop-down list in the rollout. The user can click open the list and scroll or click again to select an item in the list.

The syntax is:

dropdownlist <name> [<caption>] [items:<array_of_strings>] [selection:<number>] [height:<number>] [tooltip:<string>] 

The default alignment of dropdownList items is #left .

FOR EXAMPLE:

rollout ddl_test "Drop-Down List"
(
  dropdownlist scale_dd "Scale" items:#("1/2", "1/4", "1/8", "1/16")
  on scale_dd selected i do
    format "You selected '%'!\n" scale_dd.items[i]
)
createDialog ddl_test

   

Parameters:

items:   

The array of text strings that are the items in the list.

   

selection: 

The 1-based number of the currently selected item in the list. Defaults to 1.

   

height: 

The overall height of the dropdownlist in number of item lines. Defaults to 10 lines. To have a dropdownlist exactly display N items in the list, set height to N+1 .

The minimum height value is clamped to 1 line.

FOR EXAMPLE:

rollouttest "Test" 
(
dropdownlist dd "dd"\
items:#("1","2","3","4","5","6","7","8","9","10") height:6
label l "L"
) 
createDialog test 200 200
--You will get 5 items in the dropdown list. --Change height to 5, and you will get 4. 

   

tooltip: 

A string defining the tooltip to be displayed when the mouse rolls over the dropdownlist. Available in 3ds Max 2009 and higher.

   

Properties:

<dropdownlist>.items Array 

Get/Set the item string array.

   

<dropdownlist>.selection Integer 

The currently selected item number, 1-based. If the items list is an empty array, this value is 0.

   

<dropdownlist>.selected String 

The text of the currently selected item. Can be set to replace individual items without resetting the entire items array. If the items list is an empty array, this value is undefined .

   

<dropdownlist>.width Integer 

Get/set the width of the dropdownlist in pixels.

   

<dropdownlist>.height Integer 

Get/set the height of the dropdownlist in pixels. (as opposed to lines as expected in the height: creation parameter!)

   

<dropdownlist>.tooltip String 

Get/set the tooltip of the dropdownlist. Available in 3ds Max 2009 and higher.

NOTE:

A limitation in the MS Windows implementation of the tooltips causes only the first 80 characters of the tooltip string to be returned to MAXScript.

Tooltips of any length can be SET though.

   

Events:

on <dropdownlist> selected <arg> do <expr> 

Called when the user selects an item in the drop-down list. The <arg> argument will contain the new current selection item number.

NOTE:

The event handler function selected() is named identically to the .selected property, which effectively hides the function and does not allow the user to call the handler from other parts of the script the way it is possible with all other event handlers of UI controls.

See the following entry in the Frequently Asked Questions for a workaround:

How do I call the dropdownList Selected handler as a function?

   

on <dropdownlist> rightClick do <expr> 

Called when the user right-clicks the Dropdownlist control.

Available in 3ds Max 2010 and higher.

   

See Also