Changes between Version 1 and Version 2 of documentation/LuaManual/APIReference
- Timestamp:
- 05/26/12 08:20:09 (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
documentation/LuaManual/APIReference
v1 v2 8 8 For properties, there will be a type to the left in parenthesis. Get and/or Set access are indicated in the last sentence. 9 9 10 Types should be easy to decipher, with an exception where ''{}'' means a table and ''void'' means no type. 10 Types should be easy to decipher, with an exception where ''{}'' means a table and ''void'' means no type. Table examples: 11 {} = see the text for more info[[br]] 12 {type} = array of type objects[[br]] 13 {k=k_type,v=v_type} = table with k_type keys and v_type values 11 14 12 15 == rocket Table == 13 16 14 ''Context'' 17 ''Context''` `'''CreateContext'''(''string name'', ''Vector2i dimensions''):: 15 18 Creates and returns a new context called ''name'', with initial dimensions of ''dimensions''. The name of the context must be unique; if it is not, ''nil'' will be returned 16 19 17 ''bool'' 20 ''bool''` `'''LoadFontFace'''(''string font_path''):: 18 21 Loads the font face at ''font_path''. The function will return true if the font face was loaded, false if not. 19 22 20 ''void'' 23 ''void''` `'''RegisterTag'''(''string tag_name'', ''ElementInstancer instancer''):: 21 24 Registers a [wiki:documentation/LuaManual/ElementInstancer ElementInstancer] to instance when a specific XML tag is encountered in an RML file. 22 25 40 43 == Log == 41 44 42 ''void'' 45 ''void''` `'''Message'''(''logtype type'', ''string message''):: 43 46 Sends a log message to libRocket (and the attached debugger if present). This is not called from an instance of a Log object, just ''Log.Message''.[[br]] 44 47 type should be one of: 50 53 51 54 == DataSource == 52 IS THIS RIGHT? 53 '''class''' DataSource(''name'') 54 55 Abstract DataSource Interface. 56 57 '''GetNumRows'''(''table_name''):: 58 Return the number of rows in the given table 59 60 '''GetRow'''(''table_name'', ''index'', ''columns''):: 61 Return a list of the column values in string form 62 63 '''NotifyRowAdd'''(''table_name'', ''first_row_added'', ''num_rows_added''):: 55 56 Abstract DataSource Interface. Create one by calling ''DataSource.new'', and set the ''GetNumRows'' and ''GetRow'' functions to a Lua function that fits the specification. 57 58 ''DataSource''` `'''new'''(''string name''):: 59 Create a new DataSource object for use in Lua. 60 61 ''void''` `'''NotifyRowAdd'''(''string table_name'', ''int first_row_added'', ''int num_rows_added''):: 64 62 Notify listeners that rows have been added to the data source. 65 63 66 '' 'NotifyRowRemove'''(''table_name'', ''first_row_removed'', ''num_rows_removed'')::64 ''void''` `'''NotifyRowRemove'''(''string table_name'', ''int first_row_removed'', ''int num_rows_removed''):: 67 65 Notify listeners that rows have been removed from the data source. 68 66 69 '' 'NotifyRowChange'''(''table_name'', ''first_row_changed'', ''num_rows_changed'')::67 ''void''` `'''NotifyRowChange'''(''string table_name'', ''int first_row_changed'', ''int num_rows_changed''):: 70 68 Notify listeners that rows have been changed on the data source. 71 69 72 '' 'NotifyRowChange'''(''table_name'')::70 ''void''` `'''NotifyRowChange'''(''string table_name''):: 73 71 Notify listeners that all rows on the data source have changed. 74 72 73 ''int''` `'''GetNumRows''' = function(''string table_name''):: 74 To be set in Lua; return the number of rows in the given table. 75 76 `{`''string''`} `'''GetRow''' = function(''string table_name'', ''int index'', `{`string`}` ''columns'') :: 77 To be set in Lua; return a table of the values of the columns in string form. 78 75 79 == Element == 76 77 '''class''' Element 78 79 The ''Element'' class has no constructor; it must be instantiated through a ''[wiki:documentation/PythonManual/APIReference#Document Document]'' object instead. It has the following methods and properties: 80 81 '''AddEventListener'''(''event'', ''listener''[, ''in_capture_phase'']):: 82 Attaches ''listener'' to this element, listening for occurrences of ''event'' in either the bubble or capture phase. If not specified, ''in_capture_phase'' will default to False.[[br]]''NOTE: Events added from python cannot be removed.'' 83 84 '''AppendChild'''(''element''):: 80 The ''Element'' global table contains a table named ''As'', where you would find the child types of ''Element'' to cast to. For example, if you are using RocketControls, to convert an element from an event to an ''ElementFormControlInput'', you could put `local input = Element.As.ElementFormControlInput(element)`. 81 82 The ''Element'' class has no constructor; it must be instantiated through a ''[wiki:documentation/LuaManual/APIReference#Document Document]'' object instead. It has the following methods and properties: 83 84 ''void''` `'''AddEventListener'''(''string event'', ''string'' OR ''function listener''[, ''bool in_capture_phase'']):: 85 Attaches ''listener'' to this element, listening for occurrences of ''event'' in either the bubble or capture phase. If not specified, ''in_capture_phase'' will default to false. [wiki:documentation/LuaManual/AttachingToEvents See also][[br]]''NOTE: Events added from Lua cannot be removed.'' 86 87 ''void''` `'''AppendChild'''(''Element element''):: 85 88 Appends ''element'' as a child to this element. 86 89 87 '' 'Blur'''()::90 ''void''` `'''Blur'''():: 88 91 Removes input focus from this element. 89 92 90 '' 'Click'''()::93 ''void''` `'''Click'''():: 91 94 Fakes a click on this element. 92 95 93 '' 'DispatchEvent'''(''event'', ''parameters'', ''interruptible'')::94 Dispatches an event to this element. The event is of type ''event''. Parameters to the event are given in the dictionary ''parameters''; the dictionary must only contain string keys and floating-point, integeror string values. ''interruptible'' determines if the event can be forced to stop propagation early.95 96 '' 'Focus'''()::96 ''void''` `'''DispatchEvent'''(''string event'', `{}` ''parameters'', ''bool interruptible''):: 97 Dispatches an event to this element. The event is of type ''event''. Parameters to the event are given in the table ''parameters''; the table must only contain string keys and floating-point, integer, boolean, Lua userdata, or string values. ''interruptible'' determines if the event can be forced to stop propagation early. 98 99 ''void''` `'''Focus'''():: 97 100 Gives input focus to this element. 98 101 99 '' 'GetAttribute'''(''name'')::102 ''[wiki:documentation/LuaManual/Variant variant]''` `'''GetAttribute'''(''string name''):: 100 103 Returns the value of the attribute named ''name''. If no such attribute exists, the empty string will be returned. 101 104 102 '' 'GetElementById'''(''id'')::105 ''Element''` `'''GetElementById'''(''string id''):: 103 106 Returns the descendant element with an id of ''id''. 104 107 105 '''GetElementsByTagName'''(''tag_name'')::108 `{`''Element''`}` '''GetElementsByTagName'''(''string tag_name''):: 106 109 Returns a list of all descendant elements with the tag of ''tag_name''. 107 110 108 '' 'HasAttribute'''(''name'')::111 ''bool''` `'''HasAttribute'''(''string name''):: 109 112 Returns True if the element has a value for the attribute named ''name'', False if not. 110 113 111 '' 'HasChildNodes'''()::114 ''bool''` `'''HasChildNodes'''():: 112 115 Returns True if the element has at least one child node, false if not. 113 116 114 '' 'InsertBefore'''(''element'', ''adjacent_element'')::117 ''void''` `'''InsertBefore'''(''Element element'', ''Element adjacent_element''):: 115 118 Inserts the element ''element'' as a child of this element, directly before ''adjacent_element'' in the list of children. 116 119 117 '' 'IsClassSet'''(''name'')::120 ''bool''` `'''IsClassSet'''(''string name''):: 118 121 Returns true if the class ''name'' is set on the element, false if not. 119 122 120 '' 'RemoveAttribute'''(''name'')::123 ''void''` `'''RemoveAttribute'''(''name''):: 121 124 Removes the attribute named ''name'' from the element. 122 125 123 '' 'RemoveChild'''(''element'')::126 ''bool''` `'''RemoveChild'''(''Element element''):: 124 127 Removes the child element ''element'' from this element. 125 128 126 '' 'ReplaceChild'''(''inserted_element'', ''replaced_element'')::129 ''void''` `'''ReplaceChild'''(''Element inserted_element'', ''Element replaced_element''):: 127 130 Replaces the child element ''replaced_element'' with ''inserted_element'' in this element's list of children. If ''replaced_element'' is not a child of this element, ''inserted_element'' will be appended onto the list instead. 128 131 129 '' 'ScrollIntoView'''(''align_with_top'')::132 ''void''` `'''ScrollIntoView'''(''bool align_with_top''):: 130 133 Scrolls this element into view if its ancestors have hidden overflow. If ''align_with_top'' is True, the element's top edge will be aligned with the top (or as close as possible to the top) of its ancestors' viewing windows. If False, its bottom edge will be aligned to the bottom. 131 134 132 '' 'SetAttribute'''(''name'', ''value'')::135 ''void''` `'''SetAttribute'''(''string name'', ''string value''):: 133 136 Sets the value of the attribute named ''name'' to ''value''. 134 137 135 '' 'SetClass'''(''name'', ''value'')::138 ''void''` `'''SetClass'''(''string name'', ''bool value''):: 136 139 Sets (if ''value'' is true) or clears (if ''value'' is false) the class ''name'' on the element. 137 140 138 '''attributes''' ::139 The array of attributes on the element. Each element has the read-only properties ''name'' and ''value''. Read-only.140 141 '''child_nodes''' ::141 '''attributes'''` `(`{k`=''string'',`v`=''[wiki:documentation/LuaManual/Variant variant]''`}`):: 142 The array of attributes on the element. Read-only [wiki:documentation/LuaManual/ProxyTables proxy table]. 143 144 '''child_nodes'''` `(`{`''Element''`}`):: 142 145 The array of child nodes on the element. Read-only. 143 146 144 '''class_name''' ::145 The space-separated list of classes on the element. 146 147 '''client_left''' ::147 '''class_name'''` `(''string''):: 148 The space-separated list of classes on the element. Read & write. 149 150 '''client_left'''` `(''float''):: 148 151 The distance between the left border edge and the left client edge of the element. Read-only. 149 152 150 '''client_height''' ::153 '''client_height'''` `(''float''):: 151 154 The height of the element's client area. Read-only. 152 155 153 '''client_top''' ::156 '''client_top'''` `(''float''):: 154 157 The distance between the top border edge and the top client edge of the element. Read-only. 155 158 156 '''client_width''' ::159 '''client_width'''` `(''float''):: 157 160 The width of the element's client area. Read-only. 158 161 159 '''first_child''' ::160 The first child of the element, or Noneif the client has no children. Read-only.161 162 '''id''' ::163 The ID of the element, or the empty string if the element has no ID. 164 165 '''inner_rml''' ::166 The element's RML content. 167 168 '''last_child''' ::169 The last child of the element, or Noneif the client has no children. Read-only.170 171 '''next_sibling''' ::162 '''first_child'''` `(''Element''):: 163 The first child of the element, or nil if the client has no children. Read-only. 164 165 '''id'''` `(''string''):: 166 The ID of the element, or the empty string if the element has no ID. Read & write. 167 168 '''inner_rml'''` `(''string''):: 169 The element's RML content. Read & write. 170 171 '''last_child'''` `(''Element''):: 172 The last child of the element, or nil if the client has no children. Read-only. 173 174 '''next_sibling'''` `(''Element''):: 172 175 The element's next sibling, or None if it is the last sibling. Read-only. 173 176 174 '''offset_height''' ::177 '''offset_height'''` `(''float''):: 175 178 The height of the element, excluding margins. Read-only. 176 179 177 '''offset_left''' ::180 '''offset_left'''` `(''float''):: 178 181 The distance between the element's offset parent's left border edge and this element's left border edge. Read-only. 179 182 180 '''offset_parent''' ::183 '''offset_parent'''` `(''Element''):: 181 184 The element's offset parent. Read only. 182 185 183 '''offset_top''' ::186 '''offset_top'''` `(''float''):: 184 187 The distance between the element's offset parent's top border edge and this element's top border edge. Read-only. 185 188 186 '''offset_width''' ::189 '''offset_width'''` `(''float''):: 187 190 The width of the element, excluding margins. Read-only. 188 191 189 '''owner_document''' ::192 '''owner_document'''` `(''Document''):: 190 193 The document this element is part of. Read-only. 191 194 192 '''parent_node''' ::195 '''parent_node'''` `(''Element''):: 193 196 The element this element is directly parented to. Read-only. 194 197 195 198 '''previous_sibling''':: 196 The element's previous sibling, or Noneif it is the first sibling. Read-only.197 198 '''scroll_height''' ::199 The element's previous sibling, or nil if it is the first sibling. Read-only. 200 201 '''scroll_height'''` `(''float''):: 199 202 The height of this element's content. This will be at least as high as the client height. Read-only. 200 203 201 '''scroll_left''' ::204 '''scroll_left'''` `(''float''):: 202 205 The offset between the left edge of this element's client area and the left edge of the content area. 203 206 204 '''scroll_top''' ::207 '''scroll_top'''` `(''float''):: 205 208 The offset between the top edge of this element's client area and the top edge of the content area. 206 209 207 '''scroll_width''' ::210 '''scroll_width'''` `(''float''):: 208 211 The width of this element's content. This will be at least as wide as the client width. Read-only. 209 212 210 '''style''' ::211 An object used to access this element's style information. Individual RCSS properties can be accessed by using the name of the property as a Python property on the object itself (ie, element.style.width = "40px").212 213 '''tag_name''' ::213 '''style'''` `(`{k=`''string'',`v=`''string''`}`):: 214 An object used to access this element's style information. Read & write [wiki:documentation/LuaManual/ProxyTables proxy table]. 215 216 '''tag_name'''` `(''string''):: 214 217 The tag name used to instance this element. Read-only. 215 218