我的按钮点击事件是修改容器的可见性为显示,但是他的优先级应该是大于按钮动画,如何改为先显示按钮被点击的动画再去执行事件修改容器可见性。
Hi @RayC02 ,
Please try to use Released as the event Trigger of Button which control the Container, hope this way could help you.
Best Regards,
Wenbin
Hi @RayC02,
as your discription, this action is limited by LVGL Event mechanism, the event callback will be operated immediately once the trigger is sent.
You could try to write a costom event callback for this Button, such as using animation to do the operation after some delay.
Best Regards,
Wenbin
Hi @RayC02,
For example, you could write animation declaration in Event custom code area:
with the code like:
lv_anim_t change_op;
lv_anim_init(&change_op);
lv_anim_set_exec_cb(&change_op, anim_opa_cb);
lv_anim_set_values(&change_op, lv_obj_get_style_bg_opa(guider_ui.screen_1_cont_1, 0), 0);
lv_anim_set_time(&change_op, 100);
lv_anim_set_delay(&change_op, 200);
lv_anim_set_var(&change_op, guider_ui.screen_1_cont_1);
lv_anim_start(&change_op);
and then decalare the anim-opa-cb in custom.c/h
void anim_opa_cb(void * var, int32_t v)
{
lv_obj_set_style_bg_opa(var, v, LV_PART_MAIN);
}
Hope this could help you.
Best Regards,
Wenbin
Thank you for your answer. It's a good plan. However, my container uses flag to select visibility, you see this comment section of the code is the function I need to implement, clear its hidden attribute. I tried your code, but it still didn't meet my requirements. Is there any other way?
By the way,I've also tried replacing this code (lv_obj_get_style_bg_opa(guider_ui.screen_function_1, 0))with the following lv_obj_clear_flag code, but it doesn't work.
Hi @RayC02,
Please try to modify the callback function to:
void anim_opa_cb(void * var, int32_t v)
{
if (v == 0) {
lv_obj_clear_flag(var, LV_OBJ_FLAG_HIDDEN);
}
}
and also change the animation code:
lv_anim_set_values(&change_op, 1, 0);
Best Regards,
Wenbin