LVGL V8 - Table Cell click


Been playing with tables, and I’d like to be able to click a cell and have the event handler know what cell it was (id). But have been unsuccessfull so far. I’ve searched the forum with no success and I’ve read the docu for the tables. So far I’ve tried the below code, but it will actually spit out all the cell ID’s.

static void settingsTable_handler(lv_event_t * e)
    lv_event_code_t code = lv_event_get_code(e); 
    lv_obj_t * obj = lv_event_get_target(e);
    lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e);

    //if(code == LV_EVENT_CLICKED) {
      /*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);

I think you need lv_btnmatrix object rather than lv_table.

Use lv_table_get_selected_cell as described in lv_example_table_2.

I have tried this without success. Surely I’m doing it wrong.
Would you mind throwing me an example? :slight_smile:

Please explain more about your problem. There some examples for each object of LVGL. so did you try them?

1 Like

I did try them. What I wanted to achieve was a callback for each cell. But I ended up using the lv_list instead, which was a much better solution.