DropDown (드롭다운) Widget Control
Example file: 07_Work_with_Widgets/dropdown_objet.lfp
The Widget Controls (Property · Method · Event) you use to control the DropDown widget from a script. For an introduction to the widget and how to use it, see DropDown.
In the examples below, dropdownID is the name (ID) you assigned to the DropDown widget on the canvas. In a script, access it as widgetID.member.
Widget Control summary
| Widget Control | Kind | Signature | Description |
|---|---|---|---|
value | Property | string (Read/write) | Value of the selected item |
items | Property | array (Write-only) | Sets the list of selectable items |
onChanged | Event | onChanged = (value) => { ... } | Runs when a different item is selected |
Property
value
The value of the currently selected item. Writing sets the default selection — the value must match one of the items' value entries. Reading returns the value of the current selection.
- Type:
string - Access: Read / write
Example
// Set the default selection
dropdownID.value = "ko";
// Read the current selection
const selected = dropdownID.value;
items
Write-only. Sets the list of items a user can choose from. Each item has a title (the display text), an optional subtitle, and a value. Omit value and the title is used as the value.
- Type: array
[{ title, subtitle?, value? }] - Access: Write-only
Example
dropdownID.items = [
{ title: "Korean", subtitle: "한국어", value: "ko" },
{ title: "English", value: "en" },
];
Method
Not applicable — the DropDown widget has no dedicated Method. Use the common Widget Control below.
Event
onChanged
Runs when the user selects a different item.
- Kind: Event
- Handler arguments
value: Thevalueof the selected item
- Returns: None
Example
// When the user selects a different item in the dropdown
dropdownID.onChanged = (value) => {
// value: the value of the selected item
};
Common Widget Control (all widgets)
Every widget can also use common Widget Controls (Method) such as setProperty(name, value) / getProperty(name) / setStyleProperty(styleName, styleProperty, value). For the full rules, see the common Widget Control reference.