Module commonapi.ui
UI Interface.
Only available when native code was loaded.
Always check for presence before use.
This describes UI Version: 20190310
Info:
- Copyright: 2018-2019
- Author: Oskar Eisemuth
UI interface
Window | UI Window |
getWindow (id) | Get Window by id |
createModMenuEntry (id, caption, fn) | Creates a entry in the commonapi mod menu |
removeModMenuEntry (id) | Removes id from commonapi mod menu |
msgbox (id, text, caption) | Message Box Creator |
UI Element types
UIElement | Common to all ui elements |
Separator | |
Label | Simple text label |
Checkbox | Checkbox Control |
TextInput | Text Input Control |
Button | Button Control |
FloatValue | Float Input Control |
IntValue | Integer Input Control |
ComboBox |
Class UIWindow
UIWindow:new ([o]) | UI Window creation function |
UIWindow.id | Unique id |
UIWindow.uilist | Elements of window |
UIWindow.params | Paramater |
UIWindow.onchange | onchange callback |
UIWindow.width | Width of window |
UIWindow.height | Height of window |
UIWindow:getElementById (id) | Get element by id |
UIWindow:open () | Open this window |
UIWindow:close () | Close this window |
UI interface
- Window
-
UI Window
- Window UIWindow UI Window Class
- getWindow (id)
-
Get Window by id
Parameters:
- id string
Returns:
-
UIWindow or nil
- createModMenuEntry (id, caption, fn)
-
Creates a entry in the commonapi mod menu
Parameters:
- removeModMenuEntry (id)
-
Removes id from commonapi mod menu
Parameters:
- id ui._menulist[id] = nil
- msgbox (id, text, caption)
-
Message Box Creator
Parameters:
UI Element types
- UIElement
-
Common to all ui elements
Fields:
- typ string Type of element (Label, Button, Separator, Checkbox ...)
- visible bool (optional)
- data User defined data (To carry state as example) (optional)
See also:
Usage:
{ typ = "Button", id = "myButton1", caption = "Button1", }
- Separator
- Label
-
Simple text label
Fields:
- caption string
- Checkbox
-
Checkbox Control
Fields:
- TextInput
-
Text Input Control
Fields:
- Button
-
Button Control
Warning: container.params[id] will be set to true (this may change in the future)
Fields:
Usage:
{ typ = "Button", id = "myButton1", caption = "Button1", onclick = function(item, container) container:close() end, }
- FloatValue
-
Float Input Control
Fields:
- id string unique id
- default float (optional)
- step float (optional)
- decimalPlaces float (optional)
- minValue float (optional)
- maxValue float (optional)
- IntValue
-
Integer Input Control
Fields:
- id string unique id
- default int (optional)
- step int (optional)
- minValue int (optional)
- maxValue int (optional)
- ComboBox
-
Fields:
Class UIWindow
UIWindow Class Provides a user programmable window
Usage:
local mywin = commonapi.ui.Window:new() mywin.id = "mymodid_mwywin" mywin.caption = "Samplewindow" mywin:open()
- UIWindow:new ([o])
-
UI Window creation function
Parameters:
- o table A table to use while construction (optional)
Returns:
- UIWindow.id
-
Unique id
- id string Id of Window
- UIWindow.uilist
-
Elements of window
- uilist {UIElement,...} List of ui elements
- UIWindow.params
-
Paramater
- params table Parameters by ui element.id, may only contain modified parameters
- UIWindow.onchange
-
onchange callback will be fired when params change (by ui element)
- onchange function or nil function onchange(win)
- UIWindow.width
-
Width of window
- width int Width of window (optional)
- UIWindow.height
-
Height of window
- height int Height of window (optional)
- UIWindow:getElementById (id)
-
Get element by id
Parameters:
- id
Returns:
-
UIElement
Or
-
nil
- UIWindow:open ()
-
Open this window
Warning: Proper id of window needs to be set before use!
- UIWindow:close ()
- Close this window