Does the CYD allow gestures with LVGL? I have two working screens and I can switch between them with buttons, which is fine, but I’d much prefer to swipe between them. With the help of CoPilot, I’ve tried all kinds of stuff and have been unable to make the screen respond. I’d like to know if the CYD supports this behaviour, and if so, how do I enable it.
Thanks
Hi.
There are several elements that allow swiping.
For example, when we have two tabs, we can click on the tab name, or swipe.
I think the sliders also allow you to swipe.
I guess it will depend on the element you’re trying to control.
Regards,
Sara
In my main screen creation function, I have the following lines:
lv_obj_add_flag(mainScreen, LV_OBJ_FLAG_GESTURE_BUBBLE);
lv_obj_add_event_cb(mainScreen, mainScreen_gesture_cb, LV_EVENT_GESTURE, NULL);
lv_obj_set_scroll_dir(mainScreen, LV_DIR_ALL);
Are they the correct settings to allow swiping? It does not respond at all.
Hello Mike,
Take a look at this example:
void lv_example_tabview_1(void)
{
/*Create a Tab view object*/
lv_obj_t * tabview;
tabview = lv_tabview_create(lv_screen_active());
/*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);
lv_label_set_text(label, "This the first tab\n\n"
"If the content\n"
"of a tab\n"
"becomes too\n"
"longer\n"
"than the\n"
"container\n"
"then it\n"
"automatically\n"
"becomes\n"
"scrollable.\n"
"\n"
"\n"
"\n"
"Can you see it?");
label = lv_label_create(tab2);
lv_label_set_text(label, "Second tab");
label = lv_label_create(tab3);
lv_label_set_text(label, "Third tab");
lv_obj_scroll_to_view_recursive(label, LV_ANIM_ON);
}
That code example when you swipe left or right, it moves to the next/previous tab in the screen.
I’ve been trying to look into the documation, and I think the swipe feature is activated by default in this tab example.