Skip to content

lvgl.box

lvgl.box([parent, ]params)

Create a container for managing object layout.

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
flexFlowlvgl.FLOW_COLUMN or lvgl.FLOW_ROWenables flex layout for this box, not used by default
flexPadnumberpadding between rows/columns when flex layout is used; recommend using lvgl.PAD_xxx values, defaults to PAD_OUTLINE
scrollBarbooleanenables/disables scroll bars, defaults to true
scrollDirlvgl.SCROLL_xxallowed scroll directions when child objects extend past the box bounds (stand alone scripts only), defaults to lvgl.SCROLL_ALL
scrolledfunctioncalled when the box content is scrolled; passed x, y of the current scroll position, defaults to nil
scrollTofunctionoverrides the box scroll position; must return x, y to scroll to, defaults to nil
alignalignment type (LEFT, RIGHT, CENTER, VTOP, VBOTTOM, VCENTER) alignment used with flex layouts (added in 2.11.4); avoid combining an alignment with a scrollbar on the same axis, defaults to CENTER | VTOP
borderPadnumber or tableborder padding around the container edges; a single number applies to all sides, or a table {left=?, right=?, top=?, bottom=?} (added in 2.11.5), defaults to PAD_OUTLINE if flexFlow is set, otherwise 0

Returns

Name Type Description
- table LVGL object

Availability

  • Since: 2.11.0
  • Radio support: color-lcd

Notes

  • The box is a helper for managing screen layouts. @notice When adding controls such as button/toggle/textEdit, leave enough space around them for the focus outline. @notice In a stand alone tool script, the box automatically adds scroll bars if child objects fall outside its boundaries; for widgets, out-of-bounds children are clipped instead. @notice scrollBar, scrollDir, scrolled, and scrollTo were added in 2.11.2.

Source

radio/src/lua/api_colorlcd_lvgl.cpp