1 Formspec toolkit api 0.0.3
2 ==========================
4 Formspec toolkit is a set of functions to create basic ui elements.
10 ui.lua adds base ui interface to add additional components to.
12 ui.add(component) -> returns name of added component
14 ^ component: component to add
16 ui.delete(component) -> true/false if a component was deleted or not
17 ^ remove a component from ui
18 ^ component: component to delete
21 ^ set component to show if not a single component is set visible
22 ^ name: name of component to set as default
24 ui.find_by_name(name) --> returns component or nil
25 ^ find a component within ui
26 ^ name: name of component to look for
31 tabview_create(name, size, tabheaderpos) --> returns tabview component
32 ^ create a new tabview component
33 ^ name: name of tabview (has to be unique per ui)
34 ^ size: size of tabview
39 ^ tabheaderpos: upper left position of tabheader (relative to upper left fs corner)
45 Class reference tabview:
49 ^ add a tab to this tabview
52 name = "tabname", -- name of tab to create
53 caption = "tab caption", -- text to show for tab header
54 cbf_button_handler = function(tabview, fields, tabname, tabdata), -- callback for button events
55 --TODO cbf_events = function(tabview, event, tabname), -- callback for events
56 cbf_formspec = function(tabview, name, tabdata), -- get formspec
61 }, -- special size for this tab (only relevant if no parent for tabview set)
62 on_change = function(type,old_tab,new_tab) -- called on tab chang, type is "ENTER" or "LEAVE"
64 - set_autosave_tab(value)
65 ^ tell tabview to automatically save current tabname as "tabview_name"_LAST
68 ^ set's tab to tab named "name", returns true/false on success
69 ^ name: name of tab to set
70 - set_global_event_handler(handler)
71 ^ set a handler to be called prior calling tab specific event handler
72 ^ handler: function(tabview,event) --> returns true to finish event processing false to continue
73 - set_global_button_handler(handler)
74 ^ set a handler to be called prior calling tab specific button handler
75 ^ handler: function(tabview,fields) --> returns true to finish button processing false to continue
77 ^ set parent to attach tabview to. TV's with parent are hidden if their parent
78 is hidden and they don't set their specified size.
79 ^ parent: component to attach to
86 - set_fixed_size(state)
87 ^ true/false set to fixed size, variable size
91 Only one dialog can be shown at a time. If a dialog is closed it's parent is
92 gonna be activated and shown again.
94 dialog_create(name, cbf_formspec, cbf_button_handler, cbf_events)
95 ^ create a dialog component
96 ^ name: name of component (unique per ui)
97 ^ cbf_formspec: function to be called to get formspec
99 ^ cbf_button_handler: function to handle buttons
100 function(dialog, fields)
101 ^ cbf_events: function to handle events
102 function(dialog, event)
104 messagebox(name, message)
105 ^ creates a message dialog
107 Class reference dialog:
111 ^ set parent to attach a dialog to
112 ^ parent: component to attach to
118 ^ delete dialog from ui
122 ^ variable data attached to this dialog
124 ^ parent component to return to on exit
126 File: fst/buttonbar.lua
127 -----------------------
129 buttonbar_create(name, cbf_buttonhandler, pos, orientation, size)
131 ^ name: name of component (unique per ui)
132 ^ cbf_buttonhandler: function to be called on button pressed
133 function(buttonbar,buttonname,buttondata)
134 ^ pos: position relative to upper left of current shown formspec
139 ^ orientation: "vertical" or "horizontal"
146 Class reference buttonbar:
149 - add_button(btn_id, caption, button_image)
151 ^ set parent to attach a buttonbar to
152 ^ parent: component to attach to
158 ^ delete buttonbar from ui
162 Skeleton for any component:
164 name = "some id", -- unique id
165 type = "toplevel", -- type of component
166 -- toplevel: component can be show without additional components
167 -- addon: component is an addon to be shown along toplevel component
168 hide = function(this) end, -- called to hide the component
169 show = function(this) end, -- called to show the component
170 delete = function(this) end, -- called to delete component from ui
171 handle_buttons = function(this,fields) -- called upon button press
172 handle_events = function(this,event) -- called upon event reception
173 get_formspec = function(this) -- has to return formspec to be displayed