checkbox: allow setting _getValue later
This commit is contained in:
+1
-1
@@ -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_PART_MAIN);
|
||||||
lv_obj_set_style_bg_color(lvobj, makeLvColor(COLOR_THEME_DISABLED), LV_STATE_FOCUSED);
|
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_obj_add_event_cb(lvobj, checkbox_event_handler,
|
||||||
LV_EVENT_VALUE_CHANGED, this);
|
LV_EVENT_VALUE_CHANGED, this);
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ class CheckBox : public FormField
|
|||||||
_setValue = std::move(handler);
|
_setValue = std::move(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setGetValueHandler(std::function<uint8_t()> handler)
|
||||||
|
{
|
||||||
|
_getValue = std::move(handler);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string label;
|
std::string label;
|
||||||
std::function<uint8_t()> _getValue;
|
std::function<uint8_t()> _getValue;
|
||||||
|
|||||||
Reference in New Issue
Block a user