lv_event.h
API reference for lv_event.h
Functions
lv_event_desc_set_external_data
Set external data and its destructor for an event descriptor. This allows associating custom data with an event callback that will be automatically cleaned up when the event descriptor is removed or destroyed.
void lv_event_desc_set_external_data(lv_event_dsc_t *dsc, void *data, void(*free_cb)(void *data))| Name | Type | Description |
|---|---|---|
dsc | lv_event_dsc_t * | pointer to an event descriptor (from lv_obj_add_event_cb) |
data | void * | pointer to the external data to associate with the event descriptor May be NULL. |
free_cb | void(*)(void *data) | function pointer to a destructor that will be called to clean up the external data. The destructor will receive the data pointer as its parameter. May be NULL. When NULL no cleanup is performed. |
lv_event_get_count
uint32_t lv_event_get_count(lv_event_list_t *list)| Name | Type |
|---|---|
list | lv_event_list_t * |
lv_event_get_dsc
lv_event_dsc_t * lv_event_get_dsc(lv_event_list_t *list, uint32_t index)| Name | Type |
|---|---|
list | lv_event_list_t * |
index | uint32_t |
lv_event_dsc_get_cb
lv_event_cb_t lv_event_dsc_get_cb(lv_event_dsc_t *dsc)| Name | Type |
|---|---|
dsc | lv_event_dsc_t * |
lv_event_dsc_get_user_data
void * lv_event_dsc_get_user_data(lv_event_dsc_t *dsc)| Name | Type |
|---|---|
dsc | lv_event_dsc_t * |
lv_event_get_target
Get Widget originally targeted by the event. It's the same even if event was bubbled.
void * lv_event_get_target(lv_event_t *e)| Name | Type | Description |
|---|---|---|
e | lv_event_t * | pointer to the event descriptor |
Returns: void * — the target of the event_code
lv_event_get_current_target
Get current target of the event. It's the Widget for which the event handler being called. If the event is not bubbled it's the same as "normal" target.
void * lv_event_get_current_target(lv_event_t *e)| Name | Type | Description |
|---|---|---|
e | lv_event_t * | pointer to the event descriptor |
Returns: void * — pointer to the current target of the event_code
lv_event_get_code
Get event code of an event.
lv_event_code_t lv_event_get_code(lv_event_t *e)| Name | Type | Description |
|---|---|---|
e | lv_event_t * | pointer to the event descriptor |
Returns: lv_event_code_t — the event code. (E.g. LV_EVENT_CLICKED, LV_EVENT_FOCUSED, etc)
lv_event_get_param
Get parameter passed when event was sent.
void * lv_event_get_param(lv_event_t *e)| Name | Type | Description |
|---|---|---|
e | lv_event_t * | pointer to the event descriptor |
Returns: void * — pointer to the parameter
lv_event_get_user_data
Get user_data passed when event was registered on Widget.
void * lv_event_get_user_data(lv_event_t *e)| Name | Type | Description |
|---|---|---|
e | lv_event_t * | pointer to the event descriptor |
Returns: void * — pointer to the user_data
lv_event_code_get_name
Get the name of an event code.
const char * lv_event_code_get_name(lv_event_code_t code)| Name | Type | Description |
|---|---|---|
code | lv_event_code_t | the event code |
Returns: const char * — the name of the event code as a string
lv_event_send
Event callback. Events are used to notify the user of some action being taken on Widget. For details, see lv_event_t.
Send an event to the callbacks of an event list.
lv_result_t lv_event_send(lv_event_list_t *list, lv_event_t *e, bool preprocess)| Name | Type | Description |
|---|---|---|
list | lv_event_list_t * | pointer to an event list. May be NULL. When NULL there is nothing to notify and LV_RESULT_OK is returned. Widgets without spec_attr legitimately have no list. |
e | lv_event_t * | pointer to the event to send |
preprocess | bool | true: send only to the preprocess callbacks |
Returns: lv_result_t — LV_RESULT_OK: the target wasn't deleted in the event
lv_event_add
Add an event callback to an event list.
lv_event_dsc_t * lv_event_add(lv_event_list_t *list, lv_event_cb_t cb, lv_event_code_t filter, void *user_data)| Name | Type | Description |
|---|---|---|
list | lv_event_list_t * | pointer to an event list |
cb | lv_event_cb_t | the callback to invoke when a matching event is sent |
filter | lv_event_code_t | event code to react to |
user_data | void * | custom pointer stored with the callback and retrievable inside it via lv_event_get_user_data(). May be NULL.. |
Returns: lv_event_dsc_t * — pointer to the newly created event descriptor, or NULL on failure. Can be passed to lv_event_remove_dsc() later.
lv_event_remove_dsc
bool lv_event_remove_dsc(lv_event_list_t *list, lv_event_dsc_t *dsc)| Name | Type |
|---|---|
list | lv_event_list_t * |
dsc | lv_event_dsc_t * |
lv_event_remove
bool lv_event_remove(lv_event_list_t *list, uint32_t index)| Name | Type |
|---|---|
list | lv_event_list_t * |
index | uint32_t |
lv_event_remove_all
void lv_event_remove_all(lv_event_list_t *list)| Name | Type |
|---|---|
list | lv_event_list_t * |
lv_event_stop_bubbling
Stop event from bubbling. This is only valid when called in the middle of an event processing chain.
void lv_event_stop_bubbling(lv_event_t *e)| Name | Type | Description |
|---|---|---|
e | lv_event_t * | pointer to the event descriptor |
lv_event_stop_trickling
Stop event from trickling down to children. This is only valid when called in the middle of an event processing chain.
void lv_event_stop_trickling(lv_event_t *e)| Name | Type | Description |
|---|---|---|
e | lv_event_t * | pointer to the event descriptor |
lv_event_stop_processing
Stop processing this event. This is only valid when called in the middle of an event processing chain.
void lv_event_stop_processing(lv_event_t *e)| Name | Type | Description |
|---|---|---|
e | lv_event_t * | pointer to the event descriptor |
lv_event_free_user_data_cb
Helper function typically used in LV_EVENT_DELETE to free the event's user_data
void lv_event_free_user_data_cb(lv_event_t *e)| Name | Type | Description |
|---|---|---|
e | lv_event_t * | pointer to an event descriptor |
lv_event_register_id
Register a new, custom event ID. It can be used the same way as e.g. LV_EVENT_CLICKED to send custom events
Example:
uint32_t LV_EVENT_MINE = 0;
...
e = lv_event_register_id();
...
lv_obj_send_event(obj, LV_EVENT_MINE, &some_data);uint32_t lv_event_register_id(void)Returns: uint32_t — the new event id, or LV_EVENT_LAST if LV_EVENT_LAST_CUSTOM is reached
Enums
lv_event_code_t
Type of event being sent to Widget
| Name | Value | Description |
|---|---|---|
LV_EVENT_ALL | 0 | |
LV_EVENT_PRESSED | Input device events Widget has been pressed | |
LV_EVENT_PRESSING | Widget is being pressed (sent continuously while pressing) | |
LV_EVENT_PRESS_LOST | Widget is still being pressed but slid cursor/finger off Widget | |
LV_EVENT_SHORT_CLICKED | Widget was pressed for a short period of time, then released. Not sent if scrolled. | |
LV_EVENT_SINGLE_CLICKED | Sent for first short click within a small distance and short time | |
LV_EVENT_DOUBLE_CLICKED | Sent for second short click within small distance and short time | |
LV_EVENT_TRIPLE_CLICKED | Sent for third short click within small distance and short time | |
LV_EVENT_LONG_PRESSED | Object has been pressed for at least long_press_time. Not sent if scrolled. | |
LV_EVENT_LONG_PRESSED_REPEAT | Sent after long_press_time in every long_press_repeat_time ms. Not sent if scrolled. | |
LV_EVENT_CLICKED | Sent on release if not scrolled (regardless to long press) | |
LV_EVENT_RELEASED | Sent in every cases when Widget has been released | |
LV_EVENT_SCROLL_BEGIN | Scrolling begins. The event parameter is a pointer to the animation of the scroll. Can be modified | |
LV_EVENT_SCROLL_THROW_BEGIN | ||
LV_EVENT_SCROLL_END | Scrolling ends | |
LV_EVENT_SCROLL | Scrolling | |
LV_EVENT_GESTURE | A gesture is detected. Get gesture with lv_indev_get_gesture_dir(lv_indev_active()); | |
LV_EVENT_GESTURE_UP | An upwards gesture is detected. Sent right after LV_EVENT_GESTURE. | |
LV_EVENT_GESTURE_DOWN | A downwards gesture is detected. Sent right after LV_EVENT_GESTURE. | |
LV_EVENT_GESTURE_LEFT | A leftwards gesture is detected. Sent right after LV_EVENT_GESTURE. | |
LV_EVENT_GESTURE_RIGHT | A rightwards gesture is detected. Sent right after LV_EVENT_GESTURE. | |
LV_EVENT_KEY | A key is sent to Widget. Get key with lv_indev_get_key(lv_indev_active()); | |
LV_EVENT_ROTARY | An encoder or wheel was rotated. Get rotation count with lv_event_get_rotary_diff(e); | |
LV_EVENT_FOCUSED | Widget received focus | |
LV_EVENT_DEFOCUSED | Widget's focus has been lost | |
LV_EVENT_LEAVE | Widget's focus has been lost but is still selected | |
LV_EVENT_HIT_TEST | Perform advanced hit-testing | |
LV_EVENT_INDEV_RESET | Indev has been reset | |
LV_EVENT_HOVER_OVER | Indev hover over object | |
LV_EVENT_HOVER_LEAVE | Indev hover leave object | |
LV_EVENT_COVER_CHECK | Drawing events Check if Widget fully covers an area. The event parameter is lv_cover_check_info_t *. | |
LV_EVENT_REFR_EXT_DRAW_SIZE | Get required extra draw area around Widget (e.g. for shadow). The event parameter is int32_t * to store the size. | |
LV_EVENT_DRAW_MAIN_BEGIN | Starting the main drawing phase | |
LV_EVENT_DRAW_MAIN | Perform the main drawing | |
LV_EVENT_DRAW_MAIN_END | Finishing the main drawing phase | |
LV_EVENT_DRAW_POST_BEGIN | Starting the post draw phase (when all children are drawn) | |
LV_EVENT_DRAW_POST | Perform the post draw phase (when all children are drawn) | |
LV_EVENT_DRAW_POST_END | Finishing the post draw phase (when all children are drawn) | |
LV_EVENT_DRAW_TASK_ADDED | Adding a draw task. The LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS flag needs to be set | |
LV_EVENT_VALUE_CHANGED | Special events Widget's value has changed (i.e. slider moved) | |
LV_EVENT_INSERT | Text has been inserted into Widget. The event data is char * being inserted. | |
LV_EVENT_REFRESH | Notify Widget to refresh something on it (for user) | |
LV_EVENT_READY | A process has finished | |
LV_EVENT_CANCEL | A process has been cancelled | |
LV_EVENT_STATE_CHANGED | The state of the widget changed | |
LV_EVENT_CHECKED | A checkable Widget became checked. Sent right after LV_EVENT_VALUE_CHANGED. | |
LV_EVENT_UNCHECKED | A checkable Widget became unchecked. Sent right after LV_EVENT_VALUE_CHANGED. | |
LV_EVENT_CREATE | Other events Object is being created | |
LV_EVENT_DELETE | Object is being deleted | |
LV_EVENT_CHILD_CHANGED | Child was removed, added, or its size, position were changed | |
LV_EVENT_CHILD_CREATED | Child was created, always bubbles up to all parents | |
LV_EVENT_CHILD_DELETED | Child was deleted, always bubbles up to all parents | |
LV_EVENT_SCREEN_UNLOAD_START | A screen unload started, fired immediately when scr_load is called | |
LV_EVENT_SCREEN_LOAD_START | A screen load started, fired when the screen change delay is expired | |
LV_EVENT_SCREEN_LOADED | A screen was loaded | |
LV_EVENT_SCREEN_UNLOADED | A screen was unloaded | |
LV_EVENT_SIZE_CHANGED | Object coordinates/size have changed | |
LV_EVENT_STYLE_CHANGED | Object's style has changed | |
LV_EVENT_LAYOUT_CHANGED | A child's position position has changed due to a layout recalculation | |
LV_EVENT_GET_SELF_SIZE | Get internal size of a widget | |
LV_EVENT_INVALIDATE_AREA | Events of optional LVGL components An area is invalidated (marked for redraw). lv_event_get_param(e) returns a pointer to an lv_area_t object with the coordinates of the area to be invalidated. The area can be freely modified if needed to adapt it a special requirement of the display. Usually needed with monochrome displays to invalidate N x 8 rows or columns in one pass. | |
LV_EVENT_RESOLUTION_CHANGED | Sent when the resolution changes due to lv_display_set_resolution() or lv_display_set_rotation(). | |
LV_EVENT_COLOR_FORMAT_CHANGED | Sent as a result of any call to lv_display_set_color_format(). | |
LV_EVENT_REFR_REQUEST | Sent when something happened that requires redraw. | |
LV_EVENT_REFR_START | Sent before a refreshing cycle starts. Sent even if there is nothing to redraw. | |
LV_EVENT_REFR_READY | Sent when refreshing has been completed (after rendering and calling flush callback). Sent even if no redraw happened. | |
LV_EVENT_RENDER_START | Sent just before rendering begins. | |
LV_EVENT_RENDER_READY | Sent after rendering has been completed. | |
LV_EVENT_FLUSH_START | Sent before flush callback is called. | |
LV_EVENT_FLUSH_FINISH | Sent after flush callback call has returned. | |
LV_EVENT_FLUSH_WAIT_START | Sent before flush wait callback is called. | |
LV_EVENT_FLUSH_WAIT_FINISH | Sent after flush wait callback call has returned. | |
LV_EVENT_SYNC_START | Sent before sync callback is called. | |
LV_EVENT_SYNC_FINISH | Sent after sync callback call has returned. | |
LV_EVENT_SYNC_WAIT_START | Sent before sync wait callback is called. | |
LV_EVENT_SYNC_WAIT_FINISH | Sent after sync wait callback call has returned. | |
LV_EVENT_UPDATE_LAYOUT_COMPLETED | Sent after layout update completes | |
LV_EVENT_VSYNC | ||
LV_EVENT_VSYNC_REQUEST | ||
LV_EVENT_TRANSLATION_LANGUAGE_CHANGED | Sent when the translation language changed. | |
LV_EVENT_LAST | ||
LV_EVENT_LAST_CUSTOM | 0x7FFF | Number of default events |
LV_EVENT_PREPROCESS | 0x8000 | Sentinel for the last custom event code |
LV_EVENT_MARKED_DELETING | 0x10000 | This is a flag that can be set with an event so it's processed before the class default event processing |
Used by 21 functions
lv_gltf_model_node_add_event_cb— paramfilter_listlv_gltf_model_node_add_event_cb_with_world_position— paramfilter_listlv_event_add— paramfilterlv_event_code_get_name— paramcodelv_obj_add_screen_load_event— paramtriggerlv_obj_add_screen_create_event— paramtriggerlv_obj_add_play_timeline_event— paramtriggerlv_obj_send_event— paramevent_codelv_obj_add_event_cb— paramfilterlv_obj_add_subject_increment_event— paramtriggerlv_obj_add_subject_toggle_event— paramtriggerlv_obj_add_subject_set_int_event— paramtriggerlv_obj_add_subject_set_float_event— paramtriggerlv_obj_add_subject_set_string_event— paramtriggerlv_display_add_event_cb— paramfilterlv_display_send_event— paramcodelv_draw_unit_send_event— paramcodelv_freetype_outline_add_event— paramfilterlv_indev_add_event_cb— paramfilterlv_indev_send_event— paramcodelv_event_push_and_send— paramcode
Typedefs
lv_event_cb_t
typedef void(* lv_event_cb_t) (lv_event_t *e)Used by 13 functions
lv_gltf_model_node_add_event_cb— paramcblv_gltf_model_node_add_event_cb_with_world_position— paramcblv_event_add— paramcblv_obj_add_event_cb— paramevent_cblv_obj_remove_event_cb— paramevent_cblv_obj_remove_event_cb_with_user_data— paramevent_cblv_display_add_event_cb— paramevent_cblv_display_remove_event_cb_with_user_data— paramevent_cblv_display_register_vsync_event— paramevent_cblv_display_unregister_vsync_event— paramevent_cblv_freetype_outline_add_event— paramevent_cblv_indev_add_event_cb— paramevent_cblv_indev_remove_event_cb_with_user_data— paramevent_cb
Dependencies
Last updated on