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
getWindow (id)
Get Window by id

Parameters:

Returns:

    UIWindow or nil
createModMenuEntry (id, caption, fn)
Creates a entry in the commonapi mod menu

Parameters:

  • id string unique id for this entry
  • caption string
  • fn function callback function
removeModMenuEntry (id)
Removes id from commonapi mod menu

Parameters:

  • id ui._menulist[id] = nil
msgbox (id, text, caption)
Message Box Creator

Parameters:

  • id string unique id for this msgbox. (overwrites previous message with same id)
  • text string
  • caption string

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:

Checkbox
Checkbox Control

Fields:

  • id string unique id
  • caption string
  • default bool
  • onclick function onclick(item, container) (optional)
TextInput
Text Input Control

Fields:

Button
Button Control

Warning: container.params[id] will be set to true (this may change in the future)

Fields:

  • id string unique id
  • caption string
  • onclick function onclick(item, container) (optional)

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:

  • id string unique id
  • values table List of ComboBox Values
  • defaultIndex int (optional)
  • onclick function onclick(item, container) (optional)

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
UIWindow.id
Unique id
UIWindow.uilist
Elements of window
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
generated by LDoc 1.4.6 Last updated 2019-03-10 15:12:25