37 lines
1.0 KiB
C
37 lines
1.0 KiB
C
#include "../lv_examples.h"
|
|
#if LV_BUILD_EXAMPLES && LV_USE_FLEX
|
|
|
|
/**
|
|
* Demonstrate event trickle
|
|
*/
|
|
void lv_example_event_trickle(void)
|
|
{
|
|
lv_obj_t * cont = lv_obj_create(lv_screen_active());
|
|
lv_obj_set_size(cont, 290, 200);
|
|
lv_obj_center(cont);
|
|
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP);
|
|
|
|
static lv_style_t style_black;
|
|
lv_style_init(&style_black);
|
|
lv_style_set_text_color(&style_black, lv_color_white());
|
|
lv_style_set_bg_color(&style_black, lv_color_black());
|
|
|
|
/*Enable event trickle-down on the container*/
|
|
lv_obj_add_flag(cont, LV_OBJ_FLAG_EVENT_TRICKLE);
|
|
|
|
lv_obj_add_style(cont, &style_black, LV_STATE_PRESSED);
|
|
|
|
uint32_t i;
|
|
for(i = 0; i < 9; i++) {
|
|
lv_obj_t * subcont = lv_obj_create(cont);
|
|
lv_obj_set_size(subcont, 70, 50);
|
|
lv_obj_t * label = lv_label_create(subcont);
|
|
lv_label_set_text_fmt(label, "%" LV_PRIu32, i);
|
|
|
|
/*Add style to the label when clicked*/
|
|
lv_obj_add_style(subcont, &style_black, LV_STATE_FOCUSED);
|
|
}
|
|
}
|
|
|
|
#endif
|