Changes between Version 1 and Version 2 of documentation/LuaManual/Elements
- Timestamp:
- 06/09/12 07:00:08 (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
documentation/LuaManual/Elements
v1 v2 41 41 There are three properties of Elements that return tables of data. They are ''child_nodes'', ''attributes'', and ''style''. They are implemented in C++ as [wiki:documentation/LuaManual/ProxyTables proxy tables] with regards to their Lua interface. 42 42 43 The ''child_nodes'' property is accessed as an array; it is indexed numerically, from the front or back , and its length can be queried by getting the actual Lua table from the proxy table, and using the Lua length operator(#) on that table.43 The ''child_nodes'' property is accessed as an array; it is indexed numerically, from the front or back. 44 44 45 45 ''child_nodes'' is an array of element types. The array only includes visible elements; Lua has no way of querying [wiki:documentation/C++Manual/HiddenElements hidden elements]. The following example iterates over all of an element's children, printing their tag names, ids and classes: 46 46 47 47 {{{ 48 for key,child in ipairs(element.child_nodes :GetTable()) do48 for key,child in ipairs(element.child_nodes) do 49 49 local address = child.tag_name 50 50 67 67 68 68 {{{ 69 for name,attribute in pairs(element.attributes :GetTable()) do69 for name,attribute in pairs(element.attributes) do 70 70 print key .. ": " .. attribute 71 71 end