tabview,Arc,Slider--Enable lv_obj_set_drag_parent------touch by mistake

Description

Hi:
Using large size Arc and Slider in tabview, and enable lv_obj_set_drag_parent. (LVGL V7.10)

When turning pages, if you touch Arc, the value of Arc will be changed. It should not have changed.

Sometimes touching arc will cause page turning. It was supposed to change the value of arc instead of turning the page.

What LVGL version are you using?

LVGL V7.10

What do you want to achieve?

1.Touch page turning does not change the value of Arc and Slider.
2.When you touch to change the values of the arc and slider, the page will not turn.

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

/Create a test/

lv_obj_t* arc;
lv_obj_t* arc_label;
uint16_t arcValue;
void arc_event_cb(lv_obj_t* obj, lv_event_t event)
{
if (event == LV_EVENT_VALUE_CHANGED)
{
arcValue = lv_arc_get_value(arc);
uint8_t DataBuff[10];
sprintf(DataBuff, “%d”, arcValue);
lv_label_set_text(arc_label, DataBuff);//
}
}
void lv_tabview_Arc_Test(void)/////////////////////////////////////////////////
{
/Create a Tab view object/
lv_obj_t* tabview;
tabview = lv_tabview_create(lv_scr_act(), NULL);
lv_tabview_set_btns_pos(tabview, LV_TABVIEW_TAB_POS_NONE);/* Hide */

/*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/
lv_obj_t* tab1 = lv_tabview_add_tab(tabview, "Tab 1");
lv_obj_t* tab2 = lv_tabview_add_tab(tabview, "Tab 2");
lv_obj_t* tab3 = lv_tabview_add_tab(tabview, "Tab 3");

/*Add content to the tabs*/
lv_obj_t* label = lv_label_create(tab1, NULL);
lv_label_set_text(label, "This the first tab\n\n");
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);

/*Create an Arc*/
arc = lv_arc_create(tab1, NULL);
lv_obj_set_size(arc, 460, 460);
lv_arc_set_rotation(arc, 90);
lv_arc_set_bg_angles(arc, 0, 360);
lv_arc_set_value(arc, 50);
lv_obj_align(arc, NULL, LV_ALIGN_CENTER, 0, 0);
lv_arc_set_adjustable(arc, true);//
lv_obj_set_drag_parent(arc, true);
lv_obj_set_event_cb(arc, arc_event_cb);//

arc_label = lv_label_create(tab1, NULL);
uint8_t DataBuff[10];
sprintf(DataBuff, "%d", arcValue);
lv_label_set_text(arc_label, DataBuff);//
lv_obj_align(arc_label, arc, LV_ALIGN_CENTER, 0, 0);

label = lv_label_create(tab2, NULL);
lv_label_set_text(label, "Second tab");
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);

/*Create an Slider*/
lv_obj_t* slider = lv_slider_create(tab2, NULL);
lv_obj_set_size(slider, 460, 50);
lv_slider_set_range(slider, 0, 100);//
lv_slider_set_value(slider, 50, LV_ANIM_OFF);
lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_drag_parent(slider, true);

label = lv_label_create(tab3, NULL);
lv_label_set_text(label, "Third tab");
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);

}

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

@kisvegabor Can you help me see what’s going on, thank you

Try lv_obj_add_protect(arc, LV_PROTECT_PRESS_LOST);.

Add lv_obj_add_protect(arc, LV_PROTECT_PRESS_LOST); It doesn’t work, the problem is the same.

When you enable lv_obj_set_drag_parent, you will cause a page flip event when you want to change the arc value.

When you want to turn the page, you touch arc first, and the event will respond to arc first, and change the value of arc, so you can’t turn the page.

Can two events be prioritized?

Ah, I see.

What kind of behaviour would you expect? If you touch the arc and slide your finger LVGL can either drag the page or change the arc’s value. I have no idea how to decide automatically when to do which.

Maybe a press immediately followed by a slide is a scroll but it can be counter-intuitive.

Perhaps widgets which use dragging behavior that is not just scrolling (e.g. the slider and arc, but not the text area) should always take priority over scrolling, if their knob gets touched.

In this case, it’s up to the UI designer to leave enough space for scrolling to still be performed elsewhere on the screen.

I agree. The developer/designer needs to decide wheter to add drag_parent to an object.

Yes, now there is a conflict between two sliding events. Sliding doesn’t know who will respond first.

Can sliding events distinguish between two priorities? The events of tabview page flipping and page sliding should take precedence over the events of slider and arc.

Alternatively, the values of the slider and arc can only be changed by sliding knob. This can reduce the conflict of events.

It’s implemented for the slider with LV_SIGNAL_HIT_TEST. You can do the same for arc: