No matter which sub-option I select, the last option is always selected!
(Simulation with emulator is normal)
LVGL8.1.1 on stm32H750
This is a video demonstration:
No matter which sub-option I select, the last option is always selected!
(Simulation with emulator is normal)
LVGL8.1.1 on stm32H750
This is a video demonstration:
Please send a code snippet to reproduce (including the font you have used).
/* */
static void graph_started(lv_obj_t * parent)
{
//style_init();
lv_obj_t * btn_cout2 = lv_obj_create(parent);
lv_obj_remove_style_all(btn_cout2); /Remove the style coming from the theme/
lv_obj_add_style(btn_cout2, &style_cout, 0);
lv_obj_set_size(btn_cout2, 82, lv_pct(84)); //设置大小(宽、高),lv_pct()表示百分比
lv_obj_set_pos(btn_cout2, LV_HOR_RES-85, 40); //设置位置
lv_obj_clear_flag(btn_cout2, LV_OBJ_FLAG_SCROLLABLE);//使对象不要滚动
lv_obj_set_flex_align(btn_cout2, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND );//弹性布局
/* 通道选择下拉列表 */
static const char * opts = "通道1\n"
"通道2\n"
"通道3";
lv_obj_t * dd = lv_dropdown_create(btn_cout2);
lv_obj_remove_style_all(dd); /*Remove the style coming from the theme*/
lv_obj_add_style(dd, &style_btn, 0);
lv_obj_add_style(dd, &style_btn_pressed, LV_STATE_PRESSED);
lv_obj_set_size(dd, 76, 40); //设置大小(宽、高),lv_pct()表示百分比
lv_dropdown_set_options_static(dd, opts);//从静态字符串(全局、静态或动态分配)中设置下拉列表中的选项。 只有选项字符串的指针将被保存。
lv_dropdown_set_dir(dd, LV_DIR_LEFT);//设置列表的弹出方向
lv_dropdown_set_symbol(dd, LV_SYMBOL_DUMMY);//设置下拉列表的符号,LV_SYMBOL_DUMMY为不显示
lv_obj_t* list = lv_dropdown_get_list(dd); //要设置列表的样式,必须先获取列表
lv_obj_set_style_text_font(list, &myFont_heiti24, 0);
/* 按键1 */
lv_obj_t * btn11 = lv_btn_create(btn_cout2);
lv_obj_remove_style_all(btn11); /*Remove the style coming from the theme*/
lv_obj_add_style(btn11, &style_btn, 0);
lv_obj_add_style(btn11, &style_btn_pressed, LV_STATE_PRESSED);
lv_obj_add_style(btn11, &style_btn_checked, LV_STATE_CHECKED);
lv_obj_add_flag(btn11, LV_OBJ_FLAG_CHECKABLE);// 设置成开关类型
lv_obj_set_size(btn11, 76, 40);
lv_obj_t * labe11 = lv_label_create(btn11);
lv_label_set_text(labe11, "启 动");
lv_obj_center(labe11);
/* 按键2 */
lv_obj_t* btn12 = lv_btn_create(btn_cout2);
lv_obj_remove_style_all(btn12); /*Remove the style coming from the theme*/
lv_obj_add_style(btn12, &style_btn, 0);
lv_obj_add_style(btn12, &style_btn_pressed, LV_STATE_PRESSED);
lv_obj_set_size(btn12, 76, 40);
lv_obj_t* labe12 = lv_label_create(btn12);
lv_label_set_text(labe12, "椭 圆");
lv_obj_center(labe12);
/* 按键3 */
lv_obj_t * btn13 = lv_btn_create(btn_cout2);
lv_obj_remove_style_all(btn13); /*Remove the style coming from the theme*/
lv_obj_add_style(btn13, &style_btn, 0);
lv_obj_add_style(btn13, &style_btn_pressed, LV_STATE_PRESSED);
lv_obj_set_size(btn13, 76, 40);
lv_obj_t * labe13 = lv_label_create(btn13);
lv_label_set_text(labe13, "返 回");
lv_obj_center(labe13);
lv_obj_add_event_cb(btn11, graph_btn_click_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn12, graph_btn_click_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(btn13, graph_btn_click_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_event_cb(dd, dropdown_event_handler, LV_EVENT_ALL, NULL);
global_obj.btn_graph_confirm = btn11;
global_obj.btn_ellipse_angel = btn12;
global_obj.btn_menu_back = btn13;
global_obj.btn_channal_list = dd;
global_obj.confirm_btn_Labe = labe11;
}
/* */
display.c (42.5 KB)
Strangely enough, it works fine in the emulator
Are you sure you are using the latest LVGL version in both cases?
Please attach the myFont_heiti24
file too to reproduce it.
// SquareLine Studio version: SquareLine Studio 1.4.1
// LVGL version: 8.3.11
anyone give me advise? thanks.