Skip to content

Commit

Permalink
feat(obj): allow to create child obj inside property table (#47)
Browse files Browse the repository at this point in the history
Signed-off-by: Neo Xu <[email protected]>
  • Loading branch information
XuNeo authored May 26, 2024
1 parent 4e27ee8 commit f4b5c9c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f4b5c9c

Please sign in to comment.