You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
695 B
C
31 lines
695 B
C
2 years ago
|
#include "../lv_examples.h"
|
||
|
#if LV_BUILD_EXAMPLES && LV_USE_SWITCH
|
||
|
|
||
|
static void event_cb(lv_event_t * e)
|
||
|
{
|
||
|
LV_LOG_USER("Clicked");
|
||
|
|
||
|
static uint32_t cnt = 1;
|
||
|
lv_obj_t * btn = lv_event_get_target(e);
|
||
|
lv_obj_t * label = lv_obj_get_child(btn, 0);
|
||
|
lv_label_set_text_fmt(label, "%"LV_PRIu32, cnt);
|
||
|
cnt++;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Add click event to a button
|
||
|
*/
|
||
|
void lv_example_event_1(void)
|
||
|
{
|
||
|
lv_obj_t * btn = lv_btn_create(lv_scr_act());
|
||
|
lv_obj_set_size(btn, 100, 50);
|
||
|
lv_obj_center(btn);
|
||
|
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_CLICKED, NULL);
|
||
|
|
||
|
lv_obj_t * label = lv_label_create(btn);
|
||
|
lv_label_set_text(label, "Click me!");
|
||
|
lv_obj_center(label);
|
||
|
}
|
||
|
|
||
|
#endif
|