Dropdown

Report on GitHub

Dropdown bound to a subject; a button jumps it programmatically.

The dropdown's bind_value is wired to subject_index. A "Pick Cherry" button uses subject_set_int_event to write 2 into the subject on click — the dropdown picks up the change and updates the selection without any direct call into the dropdown widget.

Open the option list towards a specific edge.

Four dropdowns sit on the four sides of the screen and use the dir attribute to choose which way their option list pops. The default is bottom, but top, left, and right are useful when a dropdown sits close to a screen edge and there is no room to expand downward.

Mirror the selected option into a sibling label.

LV_EVENT_VALUE_CHANGED fires when a new option is chosen. lv_dropdown_get_selected returns the index; _get_selected_str reads the option text into a buffer. The handler writes that text into a sibling label.

Style the dropdown button (MAIN) with rounded corners and a focused border.

The dropdown's primary surface is MAIN (the button users tap). Local style_* props give it a card-like rounded look with padding and a custom border. A focused state style applied to MAIN brightens the border ring when the dropdown receives focus, so the example also demonstrates a state-specific style on a non-button widget.

Pin the dropdown button label regardless of selection.

Without a text attribute the dropdown shows the currently selected option (left). With text="Menu" the button always displays that string while the option list remains intact, which is useful for icon-style or fixed-label menus.

Last updated on

On this page