很多博主在LABLE应用对 lv_label_set_text_sel_start 都是一笔而过
本博主在应用中发现原code 测试后无法使用,手动选择设置没有显示,
lv_label_set_text(edit_lable,“ADCDEFGHIGK”);
lv_label_set_text_sel_start(edit_lable,1);
lv_label_set_text_sel_end(edit_lable,3);
除了打开选择配置设置项后,要添加选择样式,否则反转颜色和背景一致。
lv_obj_add_style(lable_ulcase,&style_ulcase,LV_PART_MAIN); //添加 主样式
lv_obj_add_style(lable_ulcase,&style_sle,LV_PART_SELECTED); //添加 选择样式
问题原因:
//原代码
// lv_draw_rect(draw_ctx, &draw_dsc_sel, &sel_coords);
// color = dsc->sel_color;
//修改后 new code
draw_dsc_sel.bg_color=dsc->sel_color;
lv_draw_rect(draw_ctx, &draw_dsc_sel, &sel_coords);
color = dsc->sel_bg_color;
ESP_LOGI(TAG, "sel_color=%x,%x,%x",color.ch.red,color.ch.green,color.ch.blue);//test
修改后就可以正常显示,bug已经提交,期待LVGL改进