mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-21 06:53:01 +08:00
422c9e5bd6
It encapsulates all event related parameters into a single lv_event_t obejct.
38 lines
1.4 KiB
C
38 lines
1.4 KiB
C
#include "../../lv_examples.h"
|
|
#if LV_USE_LIST && LV_BUILD_EXAMPLES
|
|
static lv_obj_t * list1;
|
|
|
|
static void event_handler(lv_event_t * e)
|
|
{
|
|
lv_event_code_t code = lv_event_get_code(e);
|
|
lv_obj_t * obj = lv_event_get_target(e);
|
|
if(code == LV_EVENT_CLICKED) {
|
|
LV_LOG_USER("Clicked: %s", lv_list_get_btn_text(list1, obj));
|
|
}
|
|
}
|
|
void lv_example_list_1(void)
|
|
{
|
|
/*Create a list*/
|
|
list1 = lv_list_create(lv_scr_act());
|
|
lv_obj_set_size(list1, 180, 220);
|
|
lv_obj_center(list1);
|
|
|
|
/*Add buttons to the list*/
|
|
lv_list_add_text(list1, "File");
|
|
lv_list_add_btn(list1, LV_SYMBOL_FILE, "New", event_handler);
|
|
lv_list_add_btn(list1, LV_SYMBOL_DIRECTORY, "Open", event_handler);
|
|
lv_list_add_btn(list1, LV_SYMBOL_SAVE, "Save", event_handler);
|
|
lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Delete", event_handler);
|
|
lv_list_add_btn(list1, LV_SYMBOL_EDIT, "Edit", event_handler);
|
|
lv_list_add_text(list1, "Connectivity");
|
|
lv_list_add_btn(list1, LV_SYMBOL_BLUETOOTH, "Bluetooth", event_handler);
|
|
lv_list_add_btn(list1, LV_SYMBOL_GPS, "Navigation", event_handler);
|
|
lv_list_add_btn(list1, LV_SYMBOL_USB, "USB", event_handler);
|
|
lv_list_add_btn(list1, LV_SYMBOL_BATTERY_FULL, "Battery", event_handler);
|
|
lv_list_add_text(list1, "Exit");
|
|
lv_list_add_btn(list1, LV_SYMBOL_OK, "Apply", event_handler);
|
|
lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Close", event_handler);
|
|
}
|
|
|
|
#endif
|