From b9dbc710c76f2d403564d6f378a4ba5412b1b082 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 19 Dec 2019 11:56:24 +0100 Subject: [PATCH] Table updates --- radio/src/thirdparty/libopenui/src/table.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/table.h b/radio/src/thirdparty/libopenui/src/table.h index bf3b3fb5b..cbe98d386 100644 --- a/radio/src/thirdparty/libopenui/src/table.h +++ b/radio/src/thirdparty/libopenui/src/table.h @@ -72,12 +72,14 @@ class Table: public Window { void paint(BitmapBuffer * dc) override; #if defined(HARDWARE_TOUCH) - bool onTouchEnd(coord_t x, coord_t y) + bool onTouchEnd(coord_t x, coord_t y) override { unsigned index = y / TABLE_LINE_HEIGHT; - auto onPress = lines[index].onPress; - if (onPress) - onPress(); + if (index < lines.size()) { + auto onPress = lines[index].onPress; + if (onPress) + onPress(); + } return true; } #endif @@ -112,6 +114,12 @@ class Table: public Window { return body.selection; } + void clearSelection() + { + body.selection = -1; + body.invalidate(); + } + void setSelection(int index, bool scroll = false) { body.selection = index; @@ -143,6 +151,7 @@ class Table: public Window { void clear() { body.clear(); + clearSelection(); } protected: