Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(obj): allow to omit the nil parent #48

Merged
merged 1 commit into from
Jun 13, 2024
Merged

feat(obj): allow to omit the nil parent #48

merged 1 commit into from
Jun 13, 2024

Conversation

XuNeo
Copy link
Owner

@XuNeo XuNeo commented Jun 12, 2024

Check if the first parameter is table, if so, the parent must be nil and default root is used. This allows us to create object on screen easier.

The change is pretty simple.

@@ -842,7 +842,7 @@ LUALIB_API int luavgl_obj_create_helper(lua_State *L,
   luavgl_ctx_t *ctx = luavgl_context(L);
   lv_obj_t *parent;

-  if (lua_isnoneornil(L, 1)) {
+  if (lua_type(L, 1) == LUA_TTABLE || lua_isnoneornil(L, 1)) {
     parent = ctx->root;
   } else {
     parent = luavgl_to_obj(L, 1);

Check if the first parameter is table, if so, the parent must be nil and default root is used.
This allows us to create object on screen easier.

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
@XuNeo XuNeo merged commit e16de07 into master Jun 13, 2024
1 check passed
@XuNeo XuNeo deleted the omit-nil-parent branch June 13, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant