Skip to content

lvgl.choice

lvgl.choice([parent, ]params)

Display a button showing an option value. Tapping it opens a popup menu of options to choose from, using EdgeTX styling.

Parameters

NameReqTypeDescription
parentnoobjectoptional LVGL object to attach the new object to; if omitted the object is created in the top-level script window
paramsyestable
FieldTypeDescription
xnumberposition relative to the top-left of the parent
ynumberposition relative to the top-left of the parent
wnumberwidth
hnumberheight
colorcolor or functionprimary color for the object
posfunctiondynamic position callback returning x, y
sizefunctiondynamic size callback returning w, h
visiblefunctiondynamic visibility callback
floatingbooleankeep the object fixed inside a scrollable container, added in 2.11.6, defaults to false
titlestringtext displayed in the popup menu's header, defaults to an empty string
valuestablesimple table of option strings shown in the popup; can be changed via lvgl.set() since 2.11.6, defaults to an empty list
getfunctioncalled on every refresh cycle to keep the displayed value in sync, to get the index of the currently selected option (1..number of values), defaults to nil
setfunctioncalled when the user taps a menu item; passed the selected item's index (1..number of values), defaults to nil
activefunctionsets the enabled/disabled state; must return a boolean, true to enable, defaults to nil
filterfunctioncalled for each option when the popup opens, passed the option's index; return true to show it, false to hide it, defaults to nil
popupWidthnumberwidth of the popup window, defaults to 0 (use default width)

Returns

Name Type Description
- table LVGL object, or nil if not running as a One-Time script or fullscreen widget

Availability

  • Since: 2.11.0
  • Radio support: color-lcd

Notes

  • Only available for One-Time scripts and widgets running in full screen mode -- returns nil otherwise. @notice The popup closes and set is called when the user selects an item. @notice If the user taps outside the popup or presses RTN, the popup closes without calling set.

Source

radio/src/lua/api_colorlcd_lvgl.cpp