feat(lua): add 'edited' callback to 'numberEdit' control for LVGL Lua scripts (#7077)

This commit is contained in:
philmoz
2026-02-09 09:36:43 +10:00
committed by GitHub
parent 539f722e9b
commit dd931bc31b
4 changed files with 19 additions and 1 deletions
@@ -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;