DropDownList objects contain items which can be selected by the user.

The following function creates a DropDownList, so you need to save it in a variable (so you can use it later).

Function Description
DropDownList(items, function) Creates a drop-down list containing the provided items (list of strings, e.g. [“item1”, “item2”, “item3”]).  When an item gets selected, function (optional) is called automatically.  If provided, the function should expect one parameter (string – the selected item).

For example, a drop-down list may be created as follows:

ddl1 = DropDownList(["item1", "item2", "item3"], itemSelected)

where itemSelected is a function which expects one parameter, the selected item (a string).

Once a DropDownList has been created, it may be added to a Display specifying where to place its top-left corner.

d.add(ddl1, 50, 50)