What is the right way to change the text in a table cell while in the DrawEvent Callback? I am using v8.3
I use this to change the colour of the text so something similar might work for you.
lv_obj_add_event_cb(temps.sensorTable, draw_part_event_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
static void draw_part_event_cb(lv_event_t * e)
{
lv_obj_t * obj = lv_event_get_target(e);
lv_obj_draw_part_dsc_t * dsc = (lv_obj_draw_part_dsc_t *)lv_event_get_param(e);
/*If the cells are drawn...*/
if(dsc->part == LV_PART_ITEMS) {
uint32_t row = dsc->id / lv_table_get_col_cnt(obj);
uint32_t col = dsc->id - row * lv_table_get_col_cnt(obj);
/*In the first column align the texts to the right*/
if(col == 1 || col == 2) {
dsc->label_dsc->align = LV_TEXT_ALIGN_RIGHT;
}
if(col == 3) {
dsc->label_dsc->align = LV_TEXT_ALIGN_CENTER;
}
if(lv_table_has_cell_ctrl(obj, row, col, LV_TABLE_CELL_CTRL_CUSTOM_1)) {
//Green
dsc->label_dsc->color = lv_color_hex(0x00ff00);
}
else if(lv_table_has_cell_ctrl(obj, row, col, LV_TABLE_CELL_CTRL_CUSTOM_2)) {
//Red
dsc->label_dsc->color = lv_color_hex(0xf55f5f);
}
else if(lv_table_has_cell_ctrl(obj, row, col, LV_TABLE_CELL_CTRL_CUSTOM_3)) {
dsc->label_dsc->color = lv_color_hex(0x00ffff);
}
}
}
This works for me in version 8.x but I’m not sure if it will work for you as you havent posted any code.