From a0bef1ea19e8a41ae7ca84a663dbe650ccc1d251 Mon Sep 17 00:00:00 2001 From: C47D Date: Thu, 24 Oct 2024 18:15:19 -0600 Subject: [PATCH] fix(table) Don't consider clicks outside cells when table column width is smaller than table --- src/widgets/table/lv_table.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/widgets/table/lv_table.c b/src/widgets/table/lv_table.c index 672e2861d047..91235f5df180 100644 --- a/src/widgets/table/lv_table.c +++ b/src/widgets/table/lv_table.c @@ -1003,17 +1003,29 @@ static lv_result_t get_pressed_cell(lv_obj_t * obj, uint32_t * row, uint32_t * c uint8_t idx = 0; int32_t total_row_height = 0; + int32_t total_column_width = 0; for(idx = 0; idx < table->row_cnt; ++idx) { total_row_height += *(table->row_h); } + for(idx = 0; idx < table->col_cnt; ++idx) { + total_column_width += *(table->col_w); + } + /* Clicked outside rows on empty space */ if(p.y > (total_row_height + area.y1)) { if(col) *col = LV_TABLE_CELL_NONE; if(row) *row = LV_TABLE_CELL_NONE; return LV_RESULT_INVALID; } + /* Clicked outside columns on empty space */ + else if(p.x > (total_column_width + area.x1)) { + if(col) *col = LV_TABLE_CELL_NONE; + if(row) *row = LV_TABLE_CELL_NONE; + return LV_RESULT_INVALID; + } + else { /*Nothing to do*/ } int32_t tmp; if(col) {