Quite often I update screen objects using data that server sends back to a device. To find the right object like text or a button is easy if an .id field was pre-filled with a unique string. Buttons have .id fields, so accessing them is no problem, but if it comes to a text, textfield or an image, which do not have an .id field, accessing the right object will be done through a special table, where I keep pairs “own_created_id–an_object”.
The app received id as string, finds an object in the table and now you can manipulate the object if it is found: enable/disable, change position, text, etc.
Feature request for .id field for ANY object-as-table in Solar2D was mentioned somewhere on the forum; this time I would like to raise this request again. It will give more flexibility.
Also .custom-data field where you can put a string would be nice to have, too. In this field a programmer can keep additional data as a string or a table. In my works I often see a need for such features.
I wish all the objects had modern way creation:
local R = display.newRect(
parent = parent,
x = x,
y = y,
width = width,
height = height}