Page 1 of 1

[Rseding91] Missing doc: return value of LuaGuiElement::add

Posted: Fri Sep 02, 2016 5:38 am
by Mooncat
After a long struggle and then a sudden curiosity, I realized that
LuaGuiElement::add actually returns the added GUI element!

So, instead of doing something like

Code: Select all

frame.add{type = "table", name = "my_table", colspan = 10}
local my_table = frame["my_table"]
my_table.add{.......}
you can do it like this:

Code: Select all

local my_table = frame.add{type = "table", name = "my_table", colspan = 10}
my_table.add{.......}
It is a huge difference if you are adding many GUI elements.
Some of you may have already known this, but this deserves to be on the document. :P

Re: Missing doc: return value of LuaGuiElement::add

Posted: Fri Sep 02, 2016 9:10 am
by Nexela
When you sent me over the message GUI I wondered why you didn't do that :)

Re: Missing doc: return value of LuaGuiElement::add

Posted: Fri Sep 02, 2016 9:19 am
by Mooncat
Because the doc didn't say it has a return value.

Image

edit: and I just realized the name property is optional. :| Nah, I still name every single element anyway.

Re: Missing doc: return value of LuaGuiElement::add

Posted: Fri Sep 02, 2016 9:38 am
by Nexela
Well....

Re: [Rseding91] Missing doc: return value of LuaGuiElement::add

Posted: Fri Sep 02, 2016 9:38 pm
by Rseding91
Fixed the docs for 0.14.4.

Re: [Rseding91] Missing doc: return value of LuaGuiElement::add

Posted: Fri Sep 02, 2016 9:54 pm
by Mooncat
Thanks :lol: