-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Similar to lvgl user_data, the lua lvgl obj also have user_data for user. It uses userdata's uservalue for this purpose. Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
- Loading branch information
Showing
3 changed files
with
30 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- user_data can store any type of lua value | ||
local obj1 = lvgl.Label { | ||
text_color = "#333", | ||
border_color = "#f00", | ||
border_width = 1, | ||
align = lvgl.ALIGN.TOP_LEFT | ||
} | ||
|
||
obj1.user_data = 123.456 | ||
obj1.text = "user_data:\n" .. obj1.user_data | ||
|
||
-- use user_data to store table | ||
local obj2 = lvgl.Label { | ||
text_color = "#333", | ||
border_color = "#f00", | ||
border_width = 1, | ||
align = lvgl.ALIGN.TOP_RIGHT | ||
} | ||
|
||
obj2.user_data = { | ||
abc = "hello", | ||
def = "world", | ||
[1] = 123, | ||
} | ||
obj2.text = "user_data:" | ||
for k, v in pairs(obj2.user_data) do | ||
print(k, v) | ||
obj2.text = obj2.text .. string.format("%s: %s\n", k, v) | ||
end |
This file was deleted.
Oops, something went wrong.