From 18e777a18c52626391030e4fc2c195b15b88fca8 Mon Sep 17 00:00:00 2001 From: philmoz Date: Mon, 29 Jul 2024 18:35:43 +1000 Subject: [PATCH] fix(color): restore CHANGED event handler for Choice class (#5338) Caused currently configured protocol to not be shown for MPM on colorlcd --- radio/src/thirdparty/libopenui/src/choice.cpp | 16 ++++++++++++++++ radio/src/thirdparty/libopenui/src/choice.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/radio/src/thirdparty/libopenui/src/choice.cpp b/radio/src/thirdparty/libopenui/src/choice.cpp index ae2a749e9..93fc45c9e 100644 --- a/radio/src/thirdparty/libopenui/src/choice.cpp +++ b/radio/src/thirdparty/libopenui/src/choice.cpp @@ -46,6 +46,20 @@ static lv_obj_t* choice_create(lv_obj_t* parent) return etx_create(&choice_class, parent); } +void ChoiceBase::changedCB(lv_event_t* e) +{ + auto code = lv_event_get_code(e); + + if (code == LV_EVENT_VALUE_CHANGED) { + lv_obj_t* target = lv_event_get_target(e); + if (target != nullptr) { + ChoiceBase* cb = (ChoiceBase*)lv_obj_get_user_data(target); + if (cb) + cb->update(); + } + } +} + ChoiceBase::ChoiceBase(Window* parent, const rect_t& rect, int vmin, int vmax, const char* title, std::function _getValue, @@ -65,6 +79,8 @@ ChoiceBase::ChoiceBase(Window* parent, const rect_t& rect, // Add label label = lv_label_create(lvobj); lv_obj_set_pos(label, ICON_W, PAD_TINY); + + lv_obj_add_event_cb(lvobj, changedCB, LV_EVENT_VALUE_CHANGED, this); } std::string Choice::getLabelText() diff --git a/radio/src/thirdparty/libopenui/src/choice.h b/radio/src/thirdparty/libopenui/src/choice.h index 6bc84b19f..852f87b4f 100644 --- a/radio/src/thirdparty/libopenui/src/choice.h +++ b/radio/src/thirdparty/libopenui/src/choice.h @@ -65,6 +65,8 @@ class ChoiceBase : public FormField std::function textHandler; virtual std::string getLabelText() = 0; + + static void changedCB(lv_event_t *e); }; class Choice : public ChoiceBase