From 42b98362c3189efb350d4283cc2e5896309295b7 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 19 Jun 2022 10:24:30 +0200 Subject: [PATCH] checkbox: allow setting _getValue later --- radio/src/thirdparty/libopenui/src/checkbox.cpp | 2 +- radio/src/thirdparty/libopenui/src/checkbox.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/radio/src/thirdparty/libopenui/src/checkbox.cpp b/radio/src/thirdparty/libopenui/src/checkbox.cpp index 8bee639ae..e2dc3dbd1 100644 --- a/radio/src/thirdparty/libopenui/src/checkbox.cpp +++ b/radio/src/thirdparty/libopenui/src/checkbox.cpp @@ -46,7 +46,7 @@ CheckBox::CheckBox(Window* parent, const rect_t& rect, lv_obj_set_style_bg_color(lvobj, makeLvColor(COLOR_THEME_DISABLED), LV_PART_MAIN); lv_obj_set_style_bg_color(lvobj, makeLvColor(COLOR_THEME_DISABLED), LV_STATE_FOCUSED); - if (_getValue()) lv_obj_add_state(lvobj, LV_STATE_CHECKED); + if (_getValue && _getValue()) lv_obj_add_state(lvobj, LV_STATE_CHECKED); lv_obj_add_event_cb(lvobj, checkbox_event_handler, LV_EVENT_VALUE_CHANGED, this); diff --git a/radio/src/thirdparty/libopenui/src/checkbox.h b/radio/src/thirdparty/libopenui/src/checkbox.h index 12c4210cb..46b260890 100644 --- a/radio/src/thirdparty/libopenui/src/checkbox.h +++ b/radio/src/thirdparty/libopenui/src/checkbox.h @@ -46,6 +46,11 @@ class CheckBox : public FormField _setValue = std::move(handler); } + void setGetValueHandler(std::function handler) + { + _getValue = std::move(handler); + } + protected: std::string label; std::function _getValue;