Description
Hi,
I disable the scrolling function of the container, and then drag the subcomponent of the container. Some events in the subcomponent that are not called by scrolling are triggered. How can I prevent these events from being triggered when dragging? When the container starts scrolling, some event functions will not be called
What MCU/Processor/Board and compiler are you using?
vs code
What LVGL version are you using?
v8.0
What do you want to achieve?
What have you tried so far?
Code to reproduce
The code block(s) should be formatted like:
void lv_screen_11(void)
{
lv_obj_clean(lv_scr_act());
lv_obj_t * scr = lv_obj_create(NULL);
lv_scr_load(scr);
/*******************************************************************************************************************/
c[0] = NULL;
c[0] = (struct con *)malloc(sizeof(struct con));
if (c[0] == NULL){return;}
memset(c[0], 0, sizeof(struct con));
c[0]->number=5;
c[0]->cont=lv_obj_create(lv_scr_act());
lv_obj_set_size(c[0]->cont, 680, 800);
lv_obj_align(c[0]->cont,LV_ALIGN_RIGHT_MID,0,0);
lv_obj_set_style_bg_color(c[0]->cont,lv_palette_darken(LV_PALETTE_GREY,2),0);
lv_obj_set_style_radius(c[0]->cont,0,0);
lv_obj_set_style_border_width(c[0]->cont,0,0);
lv_obj_set_style_pad_all(c[0]->cont,0,0);
lv_obj_clear_flag(c[0]->cont, LV_OBJ_FLAG_SCROLLABLE);
// lv_obj_add_flag(c[0]->cont,LV_OBJ_FLAG_SCROLLABLE);
// lv_obj_set_style_bg_opa(c[0]->cont, LV_OPA_0, LV_PART_SCROLLBAR | LV_STATE_DEFAULT);
// lv_obj_set_style_bg_opa(c[0]->cont, LV_OPA_0, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
c[1] = NULL;
c[1] = (struct con *)malloc(sizeof(struct con));
if (c[1] == NULL){return;}
memset(c[1], 0, sizeof(struct con));
c[0]->next=c[1];
c[1]->cont_1 = lv_obj_create(c[0]->cont);
c[1]->cont_2 = lv_obj_create(c[1]->cont_1);
lv_obj_set_size(c[1]->cont_1, 680, 200);
lv_obj_set_style_bg_color(c[1]->cont_1,lv_palette_darken(LV_PALETTE_GREY,2),0);
lv_obj_set_style_radius(c[1]->cont_1,0,0);
lv_obj_set_style_border_width(c[1]->cont_1,0,0);
// lv_obj_clear_flag(c[1]->cont_1,LV_OBJ_FLAG_SCROLLABLE);
lv_obj_align(c[1]->cont_1,LV_ALIGN_TOP_RIGHT,0,0);
lv_obj_set_style_pad_all(c[1]->cont_1,0,0);
lv_obj_add_event_cb(c[1]->cont_1, drag_event_handler, LV_EVENT_PRESSING, c[1]->cont_1); //
lv_obj_add_event_cb(c[1]->cont_1, drag_event_handler, LV_EVENT_RELEASED, c[1]->cont_1); //
lv_obj_t * dd;
dd = lv_dropdown_create(c[1]->cont_1);
lv_dropdown_set_options(dd,
"Normal\n"
"1 / 90\n"
"1 / 100\n"
"1 / 125\n"
"1 / 180\n"
"1 / 250\n"
"1 / 350\n"
"1 / 500\n"
"1 / 725\n"
"1 / 1000\n"
"1 / 1500\n"
"1 / 2000\n"
"1 / 3000\n"
"1 / 4000\n"
"1 / 6000\n"
"1 / 10K");
lv_dropdown_set_dir(dd, LV_DIR_BOTTOM);
lv_dropdown_set_symbol(dd, LV_SYMBOL_DOWN);
lv_obj_align(dd, LV_ALIGN_RIGHT_MID, 0, 0);
lv_obj_set_size(dd, 400,100);
lv_dropdown_set_selected(dd, 0);
add_dd_btn_style(dd);
lv_obj_add_event_cb(dd,add_dd_list_style,LV_EVENT_SHORT_CLICKED,dd);
lv_obj_add_event_cb(dd, drag_event_handler, LV_EVENT_PRESSING, c[1]->cont_1); //
lv_obj_add_event_cb(dd, drag_event_handler, LV_EVENT_RELEASED, c[1]->cont_1); //
lv_obj_set_size(c[1]->cont_2,680,100);
lv_obj_set_style_bg_color(c[1]->cont_2,lv_palette_lighten(LV_PALETTE_GREY,1),0);
lv_obj_align(c[1]->cont_2,LV_ALIGN_LEFT_MID,0,0);
lv_obj_set_style_radius(c[1]->cont_2,0,0);
lv_obj_set_style_border_width(c[1]->cont_2,0,0);
lv_obj_add_event_cb(c[1]->cont_2, drag_event_handler, LV_EVENT_PRESSING, c[1]->cont_1); //
lv_obj_add_event_cb(c[1]->cont_2, drag_event_handler, LV_EVENT_RELEASED, c[1]->cont_1); //
lv_obj_t* label;
label = lv_label_create(c[1]->cont_2); //
lv_label_set_text(label, "Stream Type"); //
lv_obj_set_style_text_font(label,&lv_font_montserrat_24,0);
lv_obj_set_style_text_color(label,lv_color_white(),0);
lv_obj_align(label,LV_ALIGN_LEFT_MID,0,0); //
}
static void drag_event_handler(lv_event_t* e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t *con_1=lv_event_get_user_data(e);
// lv_obj_t * obj = lv_event_get_target(e);
lv_indev_t* indev = lv_indev_get_act();
lv_point_t vect;
lv_indev_get_vect(indev, &vect);
// lv_coord_t x = lv_obj_get_x(con_1) + vect.x;
lv_coord_t y = lv_obj_get_y(con_1) + vect.y;
// lv_obj_set_pos(obj, x, y);
// lv_obj_set_x(con_1,x);
lv_obj_set_y(con_1,y);
}
After dragging the drop-down list, the list will pop up. I want it not to pop up when I drag it
Can give me some advice? Thank in advance