Changes between Version 1 and Version 2 of documentation/LuaManual/APIReference

Show
Ignore:
Author:
gambini (IP: 96.38.104.126)
Timestamp:
05/26/12 08:20:09 (5 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • documentation/LuaManual/APIReference

    v1 v2  
    88For properties, there will be a type to the left in parenthesis. Get and/or Set access are indicated in the last sentence. 
    99 
    10 Types should be easy to decipher, with an exception where ''{}'' means a table and ''void'' means no type. 
     10Types 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 
    1114 
    1215== rocket Table == 
    1316 
    14  ''Context'' '''CreateContext'''(''string name'', ''Vector2i dimensions''):: 
     17 ''Context''` `'''CreateContext'''(''string name'', ''Vector2i dimensions''):: 
    1518   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 
    1619 
    17  ''bool'' '''LoadFontFace'''(''string font_path''):: 
     20 ''bool''` `'''LoadFontFace'''(''string font_path''):: 
    1821   Loads the font face at ''font_path''. The function will return true if the font face was loaded, false if not. 
    1922 
    20  ''void'' '''RegisterTag'''(''string tag_name'', ''ElementInstancer instancer''):: 
     23 ''void''` `'''RegisterTag'''(''string tag_name'', ''ElementInstancer instancer''):: 
    2124   Registers a [wiki:documentation/LuaManual/ElementInstancer ElementInstancer] to instance when a specific XML tag is encountered in an RML file. 
    2225 
    4043== Log == 
    4144 
    42  ''void'' '''Message'''(''logtype type'', ''string message''):: 
     45 ''void''` `'''Message'''(''logtype type'', ''string message''):: 
    4346   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]] 
    4447   type should be one of: 
    5053 
    5154== 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 
     56Abstract 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''):: 
    6462   Notify listeners that rows have been added to the data source. 
    6563 
    66  '''NotifyRowRemove'''(''table_name'', ''first_row_removed'', ''num_rows_removed''):: 
     64 ''void''` `'''NotifyRowRemove'''(''string table_name'', ''int first_row_removed'', ''int num_rows_removed''):: 
    6765   Notify listeners that rows have been removed from the data source. 
    6866 
    69  '''NotifyRowChange'''(''table_name'', ''first_row_changed'', ''num_rows_changed''):: 
     67 ''void''` `'''NotifyRowChange'''(''string table_name'', ''int first_row_changed'', ''int num_rows_changed''):: 
    7068   Notify listeners that rows have been changed on the data source. 
    7169 
    72  '''NotifyRowChange'''(''table_name''):: 
     70 ''void''` `'''NotifyRowChange'''(''string table_name''):: 
    7371   Notify listeners that all rows on the data source have changed. 
    7472 
     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 
    7579== 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''):: 
     80The ''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 
     82The ''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''):: 
    8588   Appends ''element'' as a child to this element. 
    8689 
    87  '''Blur'''():: 
     90 ''void''` `'''Blur'''():: 
    8891   Removes input focus from this element. 
    8992 
    90  '''Click'''():: 
     93 ''void''` `'''Click'''():: 
    9194   Fakes a click on this element. 
    9295 
    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, integer or 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'''():: 
    97100   Gives input focus to this element. 
    98101 
    99  '''GetAttribute'''(''name''):: 
     102 ''[wiki:documentation/LuaManual/Variant variant]''` `'''GetAttribute'''(''string name''):: 
    100103   Returns the value of the attribute named ''name''. If no such attribute exists, the empty string will be returned. 
    101104 
    102  '''GetElementById'''(''id''):: 
     105 ''Element''` `'''GetElementById'''(''string id''):: 
    103106   Returns the descendant element with an id of ''id''. 
    104107 
    105  '''GetElementsByTagName'''(''tag_name''):: 
     108 `{`''Element''`}` '''GetElementsByTagName'''(''string tag_name''):: 
    106109   Returns a list of all descendant elements with the tag of ''tag_name''. 
    107110 
    108  '''HasAttribute'''(''name''):: 
     111 ''bool''` `'''HasAttribute'''(''string name''):: 
    109112   Returns True if the element has a value for the attribute named ''name'', False if not. 
    110113 
    111  '''HasChildNodes'''():: 
     114 ''bool''` `'''HasChildNodes'''():: 
    112115   Returns True if the element has at least one child node, false if not. 
    113116 
    114  '''InsertBefore'''(''element'', ''adjacent_element''):: 
     117 ''void''` `'''InsertBefore'''(''Element element'', ''Element adjacent_element''):: 
    115118   Inserts the element ''element'' as a child of this element, directly before ''adjacent_element'' in the list of children. 
    116119 
    117  '''IsClassSet'''(''name''):: 
     120 ''bool''` `'''IsClassSet'''(''string name''):: 
    118121   Returns true if the class ''name'' is set on the element, false if not. 
    119122 
    120  '''RemoveAttribute'''(''name''):: 
     123 ''void''` `'''RemoveAttribute'''(''name''):: 
    121124   Removes the attribute named ''name'' from the element. 
    122125 
    123  '''RemoveChild'''(''element''):: 
     126 ''bool''` `'''RemoveChild'''(''Element element''):: 
    124127   Removes the child element ''element'' from this element. 
    125128 
    126  '''ReplaceChild'''(''inserted_element'', ''replaced_element''):: 
     129 ''void''` `'''ReplaceChild'''(''Element inserted_element'', ''Element replaced_element''):: 
    127130   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. 
    128131 
    129  '''ScrollIntoView'''(''align_with_top''):: 
     132 ''void''` `'''ScrollIntoView'''(''bool align_with_top''):: 
    130133   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. 
    131134 
    132  '''SetAttribute'''(''name'', ''value''):: 
     135 ''void''` `'''SetAttribute'''(''string name'', ''string value''):: 
    133136   Sets the value of the attribute named ''name'' to ''value''. 
    134137 
    135  '''SetClass'''(''name'', ''value''):: 
     138 ''void''` `'''SetClass'''(''string name'', ''bool value''):: 
    136139   Sets (if ''value'' is true) or clears (if ''value'' is false) the class ''name'' on the element. 
    137140 
    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''`}`):: 
    142145   The array of child nodes on the element. Read-only. 
    143146 
    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''):: 
    148151   The distance between the left border edge and the left client edge of the element. Read-only. 
    149152 
    150  '''client_height''':: 
     153 '''client_height'''`   `(''float''):: 
    151154   The height of the element's client area. Read-only. 
    152155 
    153  '''client_top''':: 
     156 '''client_top'''`   `(''float''):: 
    154157   The distance between the top border edge and the top client edge of the element. Read-only. 
    155158 
    156  '''client_width''':: 
     159 '''client_width'''`   `(''float''):: 
    157160   The width of the element's client area. Read-only. 
    158161 
    159  '''first_child''':: 
    160    The first child of the element, or None if 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 None if 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''):: 
    172175   The element's next sibling, or None if it is the last sibling. Read-only. 
    173176 
    174  '''offset_height''':: 
     177 '''offset_height'''`   `(''float''):: 
    175178   The height of the element, excluding margins. Read-only. 
    176179 
    177  '''offset_left''':: 
     180 '''offset_left'''`   `(''float''):: 
    178181   The distance between the element's offset parent's left border edge and this element's left border edge. Read-only. 
    179182 
    180  '''offset_parent''':: 
     183 '''offset_parent'''`   `(''Element''):: 
    181184   The element's offset parent. Read only. 
    182185 
    183  '''offset_top''':: 
     186 '''offset_top'''`   `(''float''):: 
    184187   The distance between the element's offset parent's top border edge and this element's top border edge. Read-only. 
    185188 
    186  '''offset_width''':: 
     189 '''offset_width'''`   `(''float''):: 
    187190   The width of the element, excluding margins. Read-only. 
    188191 
    189  '''owner_document''':: 
     192 '''owner_document'''`   `(''Document''):: 
    190193   The document this element is part of. Read-only. 
    191194 
    192  '''parent_node''':: 
     195 '''parent_node'''`   `(''Element''):: 
    193196   The element this element is directly parented to. Read-only. 
    194197 
    195198 '''previous_sibling''':: 
    196    The element's previous sibling, or None if 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''):: 
    199202   The height of this element's content. This will be at least as high as the client height. Read-only. 
    200203 
    201  '''scroll_left''':: 
     204 '''scroll_left'''`   `(''float''):: 
    202205   The offset between the left edge of this element's client area and the left edge of the content area. 
    203206 
    204  '''scroll_top''':: 
     207 '''scroll_top'''`   `(''float''):: 
    205208   The offset between the top edge of this element's client area and the top edge of the content area. 
    206209 
    207  '''scroll_width''':: 
     210 '''scroll_width'''`   `(''float''):: 
    208211   The width of this element's content. This will be at least as wide as the client width. Read-only. 
    209212 
    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''):: 
    214217   The tag name used to instance this element. Read-only. 
    215218