Skip to content

ComboBox

phroun edited this page Aug 22, 2026 · 2 revisions

Wire name combobox

A collapsed list: one visible value, a drop-down of choices, optionally typeable.

c=new combobox children={
	new item caption="Small"
	new item caption="Medium"
	new item caption="Large"
} selected=1

Properties

Property Type Default Meaning
editable flag false Allow typing a custom value.
max_visible int Max dropdown rows shown.
placeholder string Empty-field hint text.
selected int -1 Selected index (-1 = none).

Plus the common properties.

Choices are children of the shared virtual item type, the same one ListView and TreeView use. Items cannot nest here.

Events

change — The selection changed.

Field Type Meaning
trinket uint The combo box's object ID.
selected int Index of the newly selected item, or -1 for none.

There is no separate "opened" or "closed" event — the drop-down is the trinket's own affair, and only the resulting selection crosses the wire.

Getting selected right

The same ordering rule as ListView, failing the same silent way:

new combobox selected=1 children={new item caption="A"; new item caption="B"}
  ->  selected = 0

new combobox children={new item caption="A"; new item caption="B"} selected=1
  ->  selected = 1

Write children first — or declare a template carrying the choices, which applies them before any instance property and so takes the ordering out of each caller's hands.

Editable

editable lets the user type a value instead of only choosing one, and placeholder is the hint shown while the field is empty — the same role it plays on TextInput.

An editable combo box is two things at once: a list to pick from and a field to type in. The change event reports the selected index, so a typed value that matches nothing in the list has no index to report. If free text matters to your application, read it from the field rather than inferring it from the selection.

Sizing the drop-down

max_visible caps how many rows the drop-down shows before it scrolls. It is a row count, not a size in units — the one property here that is not.

Keys and mouse

Does
Up Down Move through the choices.
Return Accept the highlighted choice, closing the drop-down.
Esc Close without changing the selection.
Click Open the drop-down; click a row to choose it.

It takes focus by Tab and by click.

See also

ListView — the same choices, always visible · RadioButton — the same choices, all visible at once · TextInput · Common Properties

Clone this wiki locally