About tileview event


When I call the following two functions:
lv_obj_set_event_cb(imgbtn, imgbtn_event);
lv_tileview_add_element(tileview, imgbtn);

When I click on this imgbtn, imgbtn will actually be clicked twice

What MCU/Processor/Board and compiler are you using?

What do you experience?

What do you expect?

Event only fires once

Code to reproduce

Screenshot and/or video

It worked well for me.

Please send a more complete code to reproduce and be sure to use the latest version of lvgl.

Not really twice, I misunderstood

There are two grids (0,0) and (0,1) in tileview, and a button in (0,0)
When I am in the button event
lv_tileview_ext_t * ext = (lv_tileview_ext_t *) lv_obj_get_ext_attr (tileview);
lv_tileview_set_tile_act (tileview, ext-> act_id.x, 1, LV_ANIM_ON);
Clicking the button tileview normally moves down to (0,1). When I want to return to (0,0) again, my hand slides down on the screen. At this time, there is no sliding animation effect.

After my test, using lv_tileview_add_element to add the button to the tileview can solve the problem of disappearing animation, but I can’t move the tileview by dragging the button.

I just said it wrong. This problem only occurs when lv_tileview_add_element is used. I commented this function to be normal.

If you still have an issue with this please a code snippet to reproduce the issue.

This is my test code,As you can see, when I press the button, tileview arrives (0,1), but I slide it back (0,0) by hand, it loses the animation effect, and it instantly returns (0,0).

 lv_obj_t *test_tileview;

void test_event(lv_obj_t *obj, lv_event_t event)
if (event == LV_EVENT_CLICKED)
lv_tileview_set_tile_act(test_tileview, 0, 1, LV_ANIM_ON);

void create()
test_tileview = lv_tileview_create(lv_scr_act(), NULL);
lv_obj_set_pos(test_tileview, 0, 0);
lv_obj_set_size(test_tileview, LV_HOR_RES, LV_VER_RES);
static lv_point_t valid_pos[] = {{0, 0}, {0, 1}};
lv_tileview_set_valid_positions(test_tileview, valid_pos, 2);

lv_obj_t *tile1 = lv_obj_create(test_tileview, NULL);
lv_obj_set_pos(tile1, 0, 0);
lv_obj_set_size(tile1, LV_HOR_RES, LV_VER_RES);
lv_obj_set_style(tile1, &lv_style_pretty);
lv_tileview_add_element(test_tileview, tile1);

lv_obj_t *test_btn = lv_btn_create(tile1, NULL);
lv_obj_align(test_btn, tile1, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_event_cb(test_btn, test_event);
lv_tileview_add_element(test_tileview, test_btn);

lv_obj_t *tile2 = lv_obj_create(test_tileview, NULL);
lv_obj_set_pos(tile2, 0, LV_VER_RES);
lv_obj_set_size(tile2, LV_HOR_RES, LV_VER_RES);
lv_obj_set_style(tile2, &lv_style_pretty);
lv_tileview_add_element(test_tileview, tile2);

lv_obj_t *label = lv_label_create(tile2, NULL);
lv_obj_align(label, tile2, LV_ALIGN_CENTER, 0, 0);

As if i didn’t reply to you


Sorry for the late replay, I was busy with some new feature of lvgl.

I’ve fixed it here:

Thank you very much for the fix, I need this fix

1 Like