feat(lua): add 'edited' callback to 'numberEdit' control for LVGL Lua scripts (#7077)
This commit is contained in:
@@ -243,6 +243,7 @@ void NumberEdit::openEdit()
|
||||
lv_obj_get_width(lvobj), lv_obj_get_height(lvobj)});
|
||||
edit->setChangeHandler([=]() {
|
||||
update();
|
||||
if (onEdited) onEdited(currentValue);
|
||||
if (edit->hasFocus())
|
||||
lv_group_focus_obj(lvobj);
|
||||
edit->hide();
|
||||
|
||||
@@ -89,6 +89,11 @@ class NumberEdit : public TextButton
|
||||
_getValue = std::move(handler);
|
||||
}
|
||||
|
||||
void setOnEditedHandler(std::function<void(int)> handler)
|
||||
{
|
||||
onEdited = std::move(handler);
|
||||
}
|
||||
|
||||
int32_t getValue() const { return _getValue != nullptr ? _getValue() : 0; }
|
||||
|
||||
protected:
|
||||
@@ -97,6 +102,7 @@ class NumberEdit : public TextButton
|
||||
NumberArea* edit = nullptr;
|
||||
std::function<int()> _getValue;
|
||||
std::function<void(int)> _setValue;
|
||||
std::function<void(int)> onEdited;
|
||||
int vdefault = 0;
|
||||
int vmin;
|
||||
int vmax;
|
||||
|
||||
Reference in New Issue
Block a user