From f4b5c9c9d15e1dbc8673e4d3f054e0401bb0fc5e Mon Sep 17 00:00:00 2001 From: Neo Xu Date: Mon, 27 May 2024 01:29:34 +0800 Subject: [PATCH] feat(obj): allow to create child obj inside property table (#47) Signed-off-by: Neo Xu --- src/obj.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/obj.c b/src/obj.c index b9e9772..3707074 100644 --- a/src/obj.c +++ b/src/obj.c @@ -819,6 +819,14 @@ static const luavgl_value_setter_t obj_property_table[] = { LUALIB_API int luavgl_obj_set_property_kv(lua_State *L, void *data) { lv_obj_t *obj = data; + + /* Check for integer key with userdata as value */ + if (lua_type(L, -2) == LUA_TNUMBER && lua_type(L, -1) == LUA_TUSERDATA) { + lv_obj_t *child = luavgl_to_obj(L, -1); + lv_obj_set_parent(child, obj); + return 0; + } + int ret = luavgl_set_property(L, obj, obj_property_table); if (ret == 0)