Release button defocus


When I press button and release out of the button area.If would be trig LV_EVENT_CLICKED too.

What LVGL version are you using?


What do you want to achieve?

I want to release the button defocus dont trig LV_EVENT_CLICKED.

Code to reproduce

lv_obj_t * label;
static void event_handler(lv_event_t * e)
    lv_obj_t* obj = lv_event_get_target(e);
    lv_event_code_t code = lv_event_get_code(e);
    static uint32_t i = 0;
    if (code == LV_EVENT_CLICKED)
        lv_label_set_text_fmt(label, "click:%d", i++);;

void test(void)
    lv_obj_t * btn = lv_btn_create(lv_scr_act());
    lv_obj_set_size(btn, 100, 50);
    lv_obj_align(btn, LV_ALIGN_CENTER, 0, 0);
    lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
    lv_obj_add_flag(lv_scr_act(), LV_OBJ_FLAG_PRESS_LOCK);

    label = lv_label_create(lv_scr_act());
    lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 0);

Screenshot and/or video


Clear this flag ‘LV_OBJ_FLAG_PRESS_LOCK’

Clear ‘LV_OBJ_FLAG_PRESS_LOCK’ still have this problem.
And it will occur another problem.Outside press and inside release button,still have click_event happen.