feat(lua): add 'edited' callback to 'numberEdit' control for LVGL Lua scripts (#7077)
This commit is contained in:
@@ -165,6 +165,7 @@ bool LvglMinMaxParams::parseMinMaxParam(lua_State *L, const char *key)
|
||||
}
|
||||
if (!strcmp(key, "max")) {
|
||||
max = luaL_checkinteger(L, -1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -2159,10 +2160,13 @@ void LvglWidgetTextEdit::build(lua_State *L)
|
||||
void LvglWidgetNumberEdit::parseParam(lua_State *L, const char *key)
|
||||
{
|
||||
if (parseMinMaxParam(L, key)) return;
|
||||
if (parseGetSetParam(L, key)) return;
|
||||
|
||||
if (!strcmp(key, "display")) {
|
||||
dispFunction = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
} else if (!parseGetSetParam(L, key)) {
|
||||
} else if (!strcmp(key, "edited")) {
|
||||
editedFunction = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
} else {
|
||||
LvglWidgetObject::parseParam(L, key);
|
||||
}
|
||||
}
|
||||
@@ -2170,6 +2174,7 @@ void LvglWidgetNumberEdit::parseParam(lua_State *L, const char *key)
|
||||
void LvglWidgetNumberEdit::clearRefs(lua_State *L)
|
||||
{
|
||||
clearRef(L, dispFunction);
|
||||
clearRef(L, editedFunction);
|
||||
clearGetSetRefs(L);
|
||||
LvglWidgetObject::clearRefs(L);
|
||||
}
|
||||
@@ -2202,6 +2207,11 @@ void LvglWidgetNumberEdit::build(lua_State *L)
|
||||
return s;
|
||||
});
|
||||
}
|
||||
if (editedFunction != LUA_REFNIL) {
|
||||
((NumberEdit*)window)->setOnEditedHandler([=]( int val) {
|
||||
pcallSetIntVal(L, editedFunction, val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user