checkbox: allow setting _getValue later

This commit is contained in:
Raphael Coeffic
2022-06-19 14:24:03 +02:00
parent ff6a0bca56
commit 42b98362c3
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -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);
+5
View File
@@ -46,6 +46,11 @@ class CheckBox : public FormField
_setValue = std::move(handler);
}
void setGetValueHandler(std::function<uint8_t()> handler)
{
_getValue = std::move(handler);
}
protected:
std::string label;
std::function<uint8_t()> _getValue;