Flags¶
Some widget attributes can be enabled or disabled using lv_obj_add_flag(widget, LV_OBJ_FLAG_...) and lv_obj_remove_flag(widget, LV_OBJ_FLAG_...).
To save memory, widgets store these flags in a bitfield. To check if a flag is set, use: lv_obj_has_flag(obj, LV_OBJ_FLAG_...).
The available flags are:
LV_OBJ_FLAG_HIDDEN
: Make the widget hidden (as if it weren’t there at all).LV_OBJ_FLAG_CLICKABLE
: Make the widget clickable by input devices.LV_OBJ_FLAG_CLICK_FOCUSABLE
: Add the focused state to the widget when clicked.LV_OBJ_FLAG_CHECKABLE
: Toggle the checked state when the widget is clicked.LV_OBJ_FLAG_SCROLLABLE
: Make the widget scrollable.LV_OBJ_FLAG_SCROLL_ELASTIC
: Allow elastic scrolling with slower movement.LV_OBJ_FLAG_SCROLL_MOMENTUM
: Enable momentum scrolling (continue scrolling when “thrown”).LV_OBJ_FLAG_SCROLL_ONE
: Allow scrolling only one snappable child.LV_OBJ_FLAG_SCROLL_CHAIN_HOR
: Propagate horizontal scrolling to the parent.LV_OBJ_FLAG_SCROLL_CHAIN_VER
: Propagate vertical scrolling to the parent.LV_OBJ_FLAG_SCROLL_CHAIN
: Shorthand forSCROLL_CHAIN_HOR | SCROLL_CHAIN_VER
.LV_OBJ_FLAG_SCROLL_ON_FOCUS
: Automatically scroll to make the widget visible when focused.LV_OBJ_FLAG_SCROLL_WITH_ARROW
: Allow scrolling the focused widget with arrow keys.LV_OBJ_FLAG_SNAPPABLE
: Allow the widget to be snapped if the parent has scroll snapping enabled.LV_OBJ_FLAG_PRESS_LOCK
: Keep the widget in the pressed state even if the pointer moves outside it.LV_OBJ_FLAG_EVENT_BUBBLE
: Propagate events to the parent.LV_OBJ_FLAG_EVENT_TRICKLE
: Propagate events to children.LV_OBJ_FLAG_STATE_TRICKLE
: Propagate state changes to children.LV_OBJ_FLAG_GESTURE_BUBBLE
: Propagate gestures to the parent.LV_OBJ_FLAG_ADV_HITTEST
: Enable more accurate hit (click) testing (e.g., account for rounded corners).LV_OBJ_FLAG_IGNORE_LAYOUT
: Exclude the widget from layout positioning.LV_OBJ_FLAG_FLOATING
: Do not scroll with the parent and ignore layout.LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS
: Enable sendingLV_EVENT_DRAW_TASK_ADDED
events.LV_OBJ_FLAG_OVERFLOW_VISIBLE
: Allow children to overflow outside the widget's bounds.LV_OBJ_FLAG_FLEX_IN_NEW_TRACK
: Start a new flex track on this item.LV_OBJ_FLAG_LAYOUT_1
: Custom flag, free to use by layouts.LV_OBJ_FLAG_LAYOUT_2
: Custom flag, free to use by layouts.LV_OBJ_FLAG_WIDGET_1
: Custom flag, free to use by widgets.LV_OBJ_FLAG_WIDGET_2
: Custom flag, free to use by widgets.LV_OBJ_FLAG_USER_1
: Custom flag, free to use by the user.LV_OBJ_FLAG_USER_2
: Custom flag, free to use by the user.LV_OBJ_FLAG_USER_3
: Custom flag, free to use by the user.LV_OBJ_FLAG_USER_4
: Custom flag, free to use by the user.
Some examples:
/* Hide a Widget */
lv_obj_add_flag(widget, LV_OBJ_FLAG_HIDDEN);
/* Make a Widget non-clickable */
lv_obj_remove_flag(widget, LV_OBJ_FLAG_CLICKABLE);
/* Check if it is clickable */
if(lv_obj_has_flag(widget, LV_OBJ_FLAG_CLICKABLE)) printf("Clickable\n");