Changes between Version 2 and Version 3 of documentation/LuaManual/APIReference
- Timestamp:
- 05/28/12 13:56:21 (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
documentation/LuaManual/APIReference
v2 v3 15 15 == rocket Table == 16 16 17 ''Context''` `'''CreateContext'''(''string name'', ''Vector2idimensions'')::17 `Context `'''CreateContext'''(`string` ''name'', `Vector2i` ''dimensions''):: 18 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 19 19 20 ''bool''` `'''LoadFontFace'''(''stringfont_path'')::20 `bool `'''LoadFontFace'''(`string` ''font_path''):: 21 21 Loads the font face at ''font_path''. The function will return true if the font face was loaded, false if not. 22 22 23 ''void''` `'''RegisterTag'''(''string tag_name'', ''ElementInstancerinstancer'')::23 `void `'''RegisterTag'''(`string` ''tag_name'', `ElementInstancer` ''instancer''):: 24 24 Registers a [wiki:documentation/LuaManual/ElementInstancer ElementInstancer] to instance when a specific XML tag is encountered in an RML file. 25 25 26 {{{{} }}}'''contexts'''::26 '''contexts'''` `(`{}`):: 27 27 A table of the active libRocket contexts. It can be indexed by string (in which case the context with the matching name is returned), or number (in which case the nth context is returned). 28 28 43 43 == Log == 44 44 45 ''void''` `'''Message'''(''logtype type'', ''stringmessage'')::45 `void `'''Message'''(`logtype` ''type'', `string` ''message''):: 46 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]] 47 47 type should be one of: 56 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 57 58 ''DataSource''` `'''new'''(''stringname'')::58 `DataSource `'''new'''(`string` ''name''):: 59 59 Create a new DataSource object for use in Lua. 60 60 61 ''void''` `'''NotifyRowAdd'''(''string table_name'', ''int first_row_added'', ''intnum_rows_added'')::61 `void `'''NotifyRowAdd'''(`string` ''table_name'', `int` ''first_row_added'', `int` ''num_rows_added''):: 62 62 Notify listeners that rows have been added to the data source. 63 63 64 ''void''` `'''NotifyRowRemove'''(''string table_name'', ''int first_row_removed'', ''intnum_rows_removed'')::64 `void `'''NotifyRowRemove'''(`string` ''table_name'', `int` ''first_row_removed'', `int` ''num_rows_removed''):: 65 65 Notify listeners that rows have been removed from the data source. 66 66 67 ''void''` `'''NotifyRowChange'''(''string table_name'', ''int first_row_changed'', ''intnum_rows_changed'')::67 `void `'''NotifyRowChange'''(`string` ''table_name'', `int` ''first_row_changed'', `int` ''num_rows_changed''):: 68 68 Notify listeners that rows have been changed on the data source. 69 69 70 ''void''` `'''NotifyRowChange'''(''stringtable_name'')::70 `void `'''NotifyRowChange'''(`string` ''table_name''):: 71 71 Notify listeners that all rows on the data source have changed. 72 72 73 ''int''` `'''GetNumRows''' = function(''stringtable_name'')::73 `int `'''GetNumRows''' = function(`string` ''table_name''):: 74 74 To be set in Lua; return the number of rows in the given table. 75 75 76 `{ `''string''`} `'''GetRow''' = function(''string table_name'', ''int index'', `{`string`}` ''columns'') ::76 `{string} `'''GetRow''' = function(`string` ''table_name'', `int` ''index'', `{string}` ''columns'') :: 77 77 To be set in Lua; return a table of the values of the columns in string form. 78 78 82 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 83 84 ''void''` `'''AddEventListener'''(''string event'', ''string'' OR ''function listener''[, ''boolin_capture_phase''])::84 `void `'''AddEventListener'''(`string` ''event'', `string` OR `function` ''listener''[, `bool` ''in_capture_phase'']):: 85 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 86 87 ''void''` `'''AppendChild'''(''Elementelement'')::87 `void `'''AppendChild'''(`Element` ''element''):: 88 88 Appends ''element'' as a child to this element. 89 89 90 ''void''``'''Blur'''()::90 `void `'''Blur'''():: 91 91 Removes input focus from this element. 92 92 93 ''void''``'''Click'''()::93 `void `'''Click'''():: 94 94 Fakes a click on this element. 95 95 96 ''void''` `'''DispatchEvent'''(''string event'', `{}` ''parameters'', ''boolinterruptible'')::96 `void `'''DispatchEvent'''(`string` ''event'', `{}` ''parameters'', `bool` ''interruptible''):: 97 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 98 99 ''void''``'''Focus'''()::99 `void `'''Focus'''():: 100 100 Gives input focus to this element. 101 101 102 ''[wiki:documentation/LuaManual/Variant variant]''` `'''GetAttribute'''( ''stringname'')::102 ''[wiki:documentation/LuaManual/Variant variant]''` `'''GetAttribute'''(`string` ''name''):: 103 103 Returns the value of the attribute named ''name''. If no such attribute exists, the empty string will be returned. 104 104 105 ''Element''` `'''GetElementById'''(''stringid'')::105 `Element `'''GetElementById'''(`string` ''id''):: 106 106 Returns the descendant element with an id of ''id''. 107 107 108 `{` ''Element''`}` '''GetElementsByTagName'''(''stringtag_name'')::108 `{`Element} `'''GetElementsByTagName'''(`string` ''tag_name''):: 109 109 Returns a list of all descendant elements with the tag of ''tag_name''. 110 110 111 ''bool''` `'''HasAttribute'''(''stringname'')::111 `bool `'''HasAttribute'''(`string` ''name''):: 112 112 Returns True if the element has a value for the attribute named ''name'', False if not. 113 113 114 ''bool''``'''HasChildNodes'''()::114 `bool `'''HasChildNodes'''():: 115 115 Returns True if the element has at least one child node, false if not. 116 116 117 ''void''` `'''InsertBefore'''(''Element element'', ''Elementadjacent_element'')::117 `void `'''InsertBefore'''(`Element` ''element'', `Element` ''adjacent_element''):: 118 118 Inserts the element ''element'' as a child of this element, directly before ''adjacent_element'' in the list of children. 119 119 203 203 204 204 '''scroll_left'''` `(''float''):: 205 The offset between the left edge of this element's client area and the left edge of the content area. 205 The offset between the left edge of this element's client area and the left edge of the content area. Read & write. 206 206 207 207 '''scroll_top'''` `(''float''):: 208 The offset between the top edge of this element's client area and the top edge of the content area. 208 The offset between the top edge of this element's client area and the top edge of the content area. Read & write. 209 209 210 210 '''scroll_width'''` `(''float''):: 219 219 == ElementText == 220 220 221 '''class''' IElementText 222 223 ''IElementText'' derives from ''Element''. ''IElementText'' is an interface, and therefore cannot be instanced directly. A concrete ''ElementText'' must be instantiated through a ''[wiki:documentation/PythonManual/APIReference#Document Document]'' object instead. It has the following property: 224 225 '''text''':: 221 ''ElementText'' derives from ''Element''. ''ElementText'' is an interface, and therefore cannot be instanced directly. A concrete ''ElementText'' must be instantiated through a ''[wiki:documentation/LuaManual/APIReference#Document Document]'' object instead. It has the following property: 222 223 '''text'''` `(''string''):: 226 224 The raw text content of the text element in UTF-8 encoding. 227 225 228 226 == Document == 229 227 230 '''class''' Document231 232 228 ''Document'' derives from ''Element''. ''Document'' has no constructor; it must be instantiated through a ''[wiki:documentation/PythonManual/APIReference#Context Context]'' object instead, either by loading an external RML file or creating an empty document. It has the following methods and properties: 233 229 234 '' 'PullToFront'''()::230 ''void''` `'''PullToFront'''():: 235 231 Pulls the document in front of other documents within its context with a similar z-index. 236 232 237 '' 'PushToBack'''()::233 ''void''` `'''PushToBack'''():: 238 234 Pushes the document behind other documents within its context with a similar z-index. 239 235 240 '' 'Show'''([''flags''])::241 Shows the document. ''flags'' is either '' NONE'', ''FOCUS'' or ''MODAL''. ''flags'' defaults to ''FOCUS''.242 243 '' 'Hide'''()::236 ''void''` `'''Show'''([''flags'']):: 237 Shows the document. ''flags'' is either ''Document.NONE'', ''Document.FOCUS'' or ''Document.MODAL''. ''flags'' defaults to ''Document.FOCUS''. 238 239 ''void''` `'''Hide'''():: 244 240 Hides the document. 245 241 246 '' 'Close'''()::242 ''void''` `'''Close'''():: 247 243 Hides and closes the document, destroying its contents. 248 244 249 '' 'CreateElement'''(''tag_name'')::245 ''Element''` `'''CreateElement'''(''tag_name''):: 250 246 Instances an element with a tag of ''tag_name''. 251 247 252 '' 'CreateTextNode'''(''text'')::248 ''ElementText''` `'''CreateTextNode'''(''text''):: 253 249 Instances a text element containing the string ''text''. 254 250 255 '''title''' ::256 The title of the document, as initially set by the <title> tag in the document's header. 257 258 '''context''' ::251 '''title'''` `(''string''):: 252 The title of the document, as initially set by the <title> tag in the document's header. Read & write. 253 254 '''context'''` `(''Context''):: 259 255 The context the document belongs to. Read-only. 260 256 261 257 == Event == 262 258 263 '''class''' Event264 265 259 The Event class has no constructor; it is generated internally. It has the following methods and properties: 266 260 267 '' 'StopPropagation'''()::261 ''void''` `'''StopPropagation'''():: 268 262 Stops the propagation of the event through the event cycle, if allowed. 269 263 270 '''current_element''' ::264 '''current_element'''` `(''Element''):: 271 265 The element the event has propagated to. Read-only. 272 266 273 '''type''' ::267 '''type'''` `(''string''):: 274 268 The string name of the event. Read-only. 275 269 276 '''target_element''' ::270 '''target_element'''` `(''Element''):: 277 271 The element the event was originally targeted at. Read-only. 278 272 279 '''parameters''' ::280 A dictionary like object containing all the parameters in the event. 273 '''parameters'''` `(`{k=`''string'',`v=`''[wiki:documentation/LuaManual/Variant variant]''):: 274 A dictionary like object containing all the parameters in the event. Read-only [wiki:documentation/LuaManual/ProxyTables proxy table]. 281 275 282 276 == Context == 283 284 '''class''' Context 285 286 The ''Context'' class has no constructor; it must be instantiated through the ''CreateContext()'' function. It has the following methods and properties: 287 288 '''AddEventListener'''(''event'', ''script'', ''element_context'', ''in_capture_phase''):: 289 Adds the inline Python script, ''script'', as an event listener to the context. ''element_context'' is an optional Element; if it is not None, then the script will be executed as if it was bound to that element. 290 291 '''AddMouseCursor'''(''cursor_document''):: 277 The ''Context'' class has no constructor; it must be instantiated through the ''rocket.CreateContext()'' function. It has the following methods and properties: 278 279 ''void''` `'''AddEventListener'''(''string event'', ''string OR function script'', ''Element element_context'', ''bool in_capture_phase''):: 280 Adds the inline Lua script, ''script'', as an event listener to the context. Rules for ''script'' are the same as the ''listener'' argument to ''Element.AddEventListener''. ''element_context'' is an optional Element; if it is not nil, then the script will be executed as if it was bound to that element. 281 282 ''void''` `'''AddMouseCursor'''(''cursor_document''):: 292 283 Adds a cursor document loaded by another context into this context. The cursor document will be returned. 293 284