Module api.gui

Contains all GUI function, tools and classes.

The GUI is a big tree containing various elements (or widgets) (called "components" and "layouts") nested together.

Most of the GUI functionality is available as soon as the application starts, within the Console State.

However, some extra functionality of the GUI is available only in the GUI State.

Other states do not have access to GUI functions and elements.

Tables

comp Contains all UI components (widgets) and base classes.
layout Contains all UI layouts and base classes.
util Contains all util function for the UI.

Class util.Rect

util.Rect.h Height of the rectangle
util.Rect.w Width of the rectangle
util.Rect.x Horizontal position of the upper left corner
util.Rect.y Vertical position of the upper left corner
util.Rect:contains(x, y) Checks if Rect contains the position on the screen.
util.Rect:intersects(other) Checks if Rect intersects another Rect.
util.Rect:new(x, y, w, h) Creates a new Rect.

Class util.MouseEvent

util.MouseEvent.button Mouse button related to the event: 0 = left, 1 = middle, 2 = right
util.MouseEvent.type Event type: 0 = mouse pressed, 1 = mouse released, 2 = mouse clicked, 3 = mouse enter, 4 = mouse exited, 5 = mouse moved, 6 = mouse wheel event, 7 = mouse double clicked
util.MouseEvent.x Horizontal position of the mouse when event was triggered
util.MouseEvent.xrel Relative horizontal position when event was triggered
util.MouseEvent.y Horizontal position of the mouse when event was triggered
util.MouseEvent.yrel Relative vertical position when event was triggered

Class util.Size

util.Alignment Alignment of the layout item
util.Orientation Orientation of the layout item
util.Size.h Height of the size
util.Size.h Height of the size element
util.Size.w Width of the size element
util.Size.w Width of the size
util.Size:new(w, h) Creates a new Size
util.downcast(layout) Properly set correct metatable of the object for most derived object

Class comp.ILayoutItem

comp.ILayoutItem:addHighPriorityProcessingComponent() Adds a component which will have priority in handling Input Actions
comp.ILayoutItem:destroy() Destroys the item: the item cannot belong to a layout of component.
comp.ILayoutItem:getBeginFrameTimes() Returns the rendering preparation time
comp.ILayoutItem:getEventTimes() Returns the events processing time
comp.ILayoutItem:getId() Obtains the id of the ui item.
comp.ILayoutItem:getRenderTimes() Returns the rendering time
comp.ILayoutItem:getStepTimes() Returns the gui update time
comp.ILayoutItem:getSwapTimes() Returns the rendering finish time
comp.ILayoutItem:removeHighPriorityProcessingComponent() Remove a component which was added via addHighPriorityProcessingComponent

Class comp.Component

comp.Component:addLifeTimeChecker() Obtains an object from the component that can be used to check whether the component has been destroyed.
comp.Component:addStyleClass(class) Assigns a style class to the component.
comp.Component:calcMinimumSize() Gets minimum size taken by the component.
comp.Component:getContentRect() Gets Rect size for the component.
comp.Component:getCore() Returns the Core object for all Components
comp.Component:getLayout() Returns layout of the component.
comp.Component:getName() Receives the name of the component.
comp.Component:getParent() Gets parent of component (automatically downcasted).
comp.Component:hasFocus() Checks if component has focus.
comp.Component:insertMouseListener(func) Prepends a mouse listener that will be called before all other listeners.
comp.Component:invokeLater(callback) Invoke a stored function at the beginning of the next frame.
comp.Component:isEnabled() Checks if the object is interactable.
comp.Component:isVisible() Checks if the object is visible.
comp.Component:new(name, id) Creates a new Component instance.
comp.Component:onDestroy(callback) Adds a callback to be called when the item is destroyed.
comp.Component:onStep(callback) Adds a callback to be called each gui update.
comp.Component:onVisibilityChange() Adds a callback to be called when the visibility changes.
comp.Component:removeMouseListener() Removes the mouse listener attached to the component.
comp.Component:removeStyleClass(class) Removes a style class to the component.
comp.Component:setEnabled(enabled) Makes the object (un)interactable.
comp.Component:setFocus() Sets a component to have focus.
comp.Component:setFocusable() Enables/disable focus on this component
comp.Component:setGravity(horizontal, vertical) Sets the alignment of the component.
comp.Component:setHighlighted(highlighted) Sets highlighted.
comp.Component:setId(id) Gives the component a unique identifier.
comp.Component:setInputActionBubbleUpAcceptFilter(a, whether) Sets a handler for a list of input actions and decide whether to enable those input actions or not
comp.Component:setInputActionForward(sourceIa, targetComp, targetIa) Forwards an input action to a target component with a specified source and target action.
comp.Component:setInputActionHandler(ia, handlerFn, func) Sets an handler for an input action, and another callback to determine whether it is enabled or not.
comp.Component:setLayout(layout) Sets a layout (the component takes ownership of the layout).
comp.Component:setMaximumSize(size) Set the maximum size that the components takes up.
comp.Component:setMinimumSize(size) Set the minimum size that the components takes up.
comp.Component:setMouseListener(func) Forwards mouse events to the component under the cursor.
comp.Component:setName(name) Gives the component a name, used to apply styles.
comp.Component:setStyleClassList(list) Assigns a style class to the component.
comp.Component:setTooltip(text) Sets the tooltip of the component.
comp.Component:setTransparent(transparent) Sets transparency.
comp.Component:setVisible(visible, emitSignal) Sets visibility.

Util

util.check(reference) Checks if a component is still alive using the LifeTimeChecker.
util.destroyLater(comp) Delete a gui element at the beginning of the next frame.
util.getById(id) Returns the component with the given id.
util.getCommandTimes() Returns commands processing time Available only within GUI State.
util.getGameUI() Returns the GameUI.
util.getInputMode() Returns the current InputMode.
util.getMouseScreenPos() Returns the screet coordinate at the mouse position.
util.getReplicateTimes() Returns the sync time between gui and simulation Available only within GUI State.
util.getStepTimes() Returns the simulation update time Available only within GUI State.

Class comp.Window

comp.Window:addHideOnCloseHandler() Adds a default handler for "onClose" that hides the window when it is closed.
comp.Window:close() Closes the window.
comp.Window:getContent() Returns the window content.
comp.Window:isAttached() Checks if window is attached.
comp.Window:isPinnable() Checks if window is pinnable.
comp.Window:isPinned() Checks if window is pinned.
comp.Window:maximize() Maximizes the window to its maximisedSize size.
comp.Window:minimize() Minimizes the window to its minimizedSize size.
comp.Window:new(title, content) Creates a new Window.
comp.Window:onClose(callback) Adds a parameterless callback, which is called when the window is closed.
comp.Window:onMove(callback) Adds a parameterless callback, which is called when the window is moved
comp.Window:remove(win) Removes a window from the UI and returns it.
comp.Window:setAttached(b) Sets the window to be attached.
comp.Window:setContent(content) Sets the window content.
comp.Window:setIcon(icon) Sets the window icon.
comp.Window:setLocateButtonVisible(b) Adds a button to follow entities and other objects.
comp.Window:setMaximiseSize() Set the size when maximised.
comp.Window:setMovable(b) Sets the window to be movable.
comp.Window:setPinButtonVisible(b) Adds a button to pin the window.
comp.Window:setPinned(b) Sets the window to be pinned.
comp.Window:setPosition(x, y) Sets the window position.
comp.Window:setResizable(b) Sets the window to be resizable.
comp.Window:setSize(size) Sets the window size.
comp.Window:setTitle(title) Sets the window title.

Class comp.GameUI

comp.GameUI:getMainRenderComponent() Obtains the main 3d scene.
comp.GameUI:getViewManager() Obtains the view manager.
comp.GameUI:playCutscene(fileName) Plays a cutscene.
comp.GameUI:playSoundEffect(name) Plays a single sound effect.
comp.GameUI:playTrack(filename, offset) Plays a single track with the music player.
comp.GameUI:setConstructionAngle(angle) Sets the default construction angle for constructions.

Class comp.RendererComponent

comp.RendererComponent:getCameraController() Gets the camera controller for the component.
comp.RendererComponent:getTerrainPos() Gets the terrain position pointed by the mouse.
comp.RendererComponent:stopAction() Stops the current Action (bulldoze, build construction, etc.)

Class util.CameraController

util.CameraController:focus(entity) Focuses the camera on an entity.
util.CameraController:follow(entity, jump) Sets camera to follow an Entity.
util.CameraController:getCameraData() Obtains the current camera data.
util.CameraController:getFollowEntity() Gets the entity currently being followed.
util.CameraController:setCameraData(center, dist, angle, pitch) Sets the camera data with custom position and other information.

Class util.ViewManager

util.ViewManager:closeAll() Closes all currently open entity windows.
util.ViewManager:openWindow(entity, above, tabIndex) Focuses the camera on an entity.

Class comp.TextInputField

comp.TextInputField:OnFocusChange(callback) Sets a callback that is called when the focus changes.
comp.TextInputField:getSelectedText() Gets selected text.
comp.TextInputField:getText() Returns the text in the input field.
comp.TextInputField:new() Creates a new text input field with placeholder text.
comp.TextInputField:onCancel(callback) Sets a callback that is called when enter is pressed.
comp.TextInputField:onChange(callback) Sets a callback that is called when the text changes.
comp.TextInputField:onEnter(callback) Sets a callback that is called when enter is pressed.
comp.TextInputField:selectAll() Selects entire text
comp.TextInputField:setDeselectOnFocusLost() Clear selection when focus is lost
comp.TextInputField:setMaxLength() Sets the maximal length of the input text.
comp.TextInputField:setText() Sets the text of the field to the given text.

Class comp.TextView

comp.TextView:getSelectedText() Gets selected text.
comp.TextView:getText() Gets the entire text.
comp.TextView:getTextAlignment() Gets the alignment of the text
comp.TextView:getTextAlignment2() Gets the alignment of the text
comp.TextView:new() Creates a new text view with some text.
comp.TextView:setSelectable() Sets the text as selectable.
comp.TextView:setText() Sets the text
comp.TextView:setTextAlignment() Sets the alignment of the text

Class comp.CheckBox

comp.CheckBox:isSelected() Return selection status for the checkbox
comp.CheckBox:new() Gets the entire text.
comp.CheckBox:onToggle(callback) Sets a callback that is called when the checkbox is selected
comp.CheckBox:setSelected(value, emit) Sets the checkbox as selected.
comp.CheckBox:setText() Sets the label text of the checkbox.

Class comp.ImageView

comp.ImageView:setImage() Sets the image of the image view.
comp.ImageView:setText() Creates a new imageview with a texture.

Class comp.ContentView

comp.ContentView:getContent() Returns the content
comp.ContentView:setContent() Sets the content (takes ownership of content)
comp.ContentView:setContentAlignment() Sets the alignment of the content

Class comp.ToggleButton

comp.ToggleButton:isSelected() TReturns whether the toggle button is toggled
comp.ToggleButton:new(child) Creates a toggle button with a child element.
comp.ToggleButton:onToggle() Calls the callback when the button is toggled
comp.ToggleButton:setSelected() TReturns whether the toggle status of the button
comp.ToggleButton:toggle() TToggles the button

Class comp.Button

comp.Button:click() Triggers a button click
comp.Button:new(child, clickOnPress) Creates a button with a child element.
comp.Button:onClick() Calls the callback when the button is clicked

Class comp.ToggleButtonGroup

comp.ToggleButtonGroup:add() Adds a new toggle button to the group, takes ownership of the button
comp.ToggleButtonGroup:getButton() Returns a button with the given index
comp.ToggleButtonGroup:getNumButtons() Returns the number of buttons
comp.ToggleButtonGroup:getSelectedIndex() Returns the index of the selected button
comp.ToggleButtonGroup:new() Creates a toggle button group.
comp.ToggleButtonGroup:onCurrentIndexChanged() Calls the callback when one button is toggled with the index of the button
comp.ToggleButtonGroup:setEmitSignal() Sets the group to trigger a signal when pressed
comp.ToggleButtonGroup:setOneButtonMustAlwaysBeSelected() Prevents deselecting all buttons

Class comp.Table

comp.Table:addRow(components) Adds a new row of components
comp.Table:deleteAll() Remove all rows and all components
comp.Table:deleteRows() Remove all rows between first and last
comp.Table:getNumCols() Gets the number of columns of the table
comp.Table:getNumRows() Gets the number of rows of the cable
comp.Table:insertRow(components) Adds a new row of components at the given index
comp.Table:new(numColumns, selectable) Create a new table with a set number of columns and an optional selection policy.
comp.Table:setColWeight() Sets the column weight (affects the width)
comp.Table:setColWidth() Set the column default width.
comp.Table:setHeader(components) Sets the header for the table
comp.Table:setMaxColWidth() Sets the column maximum width
comp.Table:setMinColWidth() Sets the column minimum width
comp.Table:setNumCols() Sets the number of columns.
comp.Table:setOrder() Sort the rows with a given order.

Class comp.ScrollArea

comp.ScrollArea:SetHorizontalScrollBarPolicy(policy) Sets the policy for the horizontal scrollbar
comp.ScrollArea:ensureVisible() Ensures a child component is visible
comp.ScrollArea:getContent() Returns content of the scroll area.
comp.ScrollArea:getScrollOffset() Returns current scroll offset.
comp.ScrollArea:getViewportRect() Return the Rect of the visible portion
comp.ScrollArea:new() Makes a new scroll area with given component and names.
comp.ScrollArea:onScroll() Sets a callback for scrolling
comp.ScrollArea:setContent() Sets the content of the scroll area
comp.ScrollArea:setScrollOffset() Scrolls to given position.
comp.ScrollArea:setVerticalScrollBarPolicy(policy) Sets the policy for the vertical scrollbar
comp.ScrollBarPolicy The visibility policy for the ScrollBar

Class comp.ComboBox

comp.ComboBox:addItem() Adds a new item at the bottom of the combo box
comp.ComboBox:addItemFactory(callback) Adds a new component at the bottom of the combo box, callback is called each time the combbox is open
comp.ComboBox:clear() Remove all entries from the combo box
comp.ComboBox:getCurrentIndex() Gets currently selected index.
comp.ComboBox:getNumItems() Returns the number of items in a layout.
comp.ComboBox:new() Makes a new empty combo box.
comp.ComboBox:onIndexChanged(callback) Add callback that is called when the current index changes.

Class comp.DoubleSpinBox

comp.DoubleSpinBox:getMaximum() Returns the current maximum possible value for the spinbox
comp.DoubleSpinBox:getMinimum() Returns the current minimum possible value for the spinbox
comp.DoubleSpinBox:getValue() Returns the current value of the spinbox
comp.DoubleSpinBox:new() Makes a new spin box with default values.
comp.DoubleSpinBox:onChange(callback) Adds a callback for when the spinbox changes value.
comp.DoubleSpinBox:setMaximum() Sets maximum selectable value for the spin box
comp.DoubleSpinBox:setMinimum() Sets minimum selectable value for the spin box
comp.DoubleSpinBox:setStep() Sets the interval between values of the spinbox
comp.DoubleSpinBox:setValue() Sets the current value of the spinbox

Class comp.SpinBox

comp.SpinBox:getValue() Returns the current value of the spinbox
comp.SpinBox:new() Makes a new spin box with default values.
comp.SpinBox:onChange(callback) Adds a callback for when the spinbox changes value.
comp.SpinBox:setRange() Sets minimum and maximum selectable values for the spin box
comp.SpinBox:setValue() Sets the current value of the spinbox

Class comp.AbstractSlider

comp.AbstractSlider:getPageStep() Gets the current page step of the slider
comp.AbstractSlider:getPageStep() Gets the current minimum value of the slider
comp.AbstractSlider:getPageStep() Gets the current maximum value of the slider
comp.AbstractSlider:getStep() Gets the current step of the slider
comp.AbstractSlider:getValue() Sets the current value of the slider
comp.AbstractSlider:onValueChanged() Get called when the slider value changes.
comp.AbstractSlider:setDefaultValue() Sets the default value of the slider
comp.AbstractSlider:setMaximum() Sets the maximum value of the slider
comp.AbstractSlider:setMinimum() Sets the minimum size of the slider
comp.AbstractSlider:setPageStep() Sets the big increment size of the slider (controlled with page buttons)
comp.AbstractSlider:setStep() Sets the increment size of the slider
comp.AbstractSlider:setValue() Sets the value of the slider

Class comp.Slider

comp.Slider:new() Creates a new vertical or horizontal slider

Class comp.Slider2

comp.Slider2:getValue() Sets the current value of the slider
comp.Slider2:new() Creates a new 2d slider
comp.Slider2:onValueChanged(callback) Adds a callback for the slider, that is called when the slider value changes
comp.Slider2:setMaximum() Sets the maximum value for the slider
comp.Slider2:setMinimum() Sets the minimum value for the slider
comp.Slider2:setValue() Sets the default value for the slider
comp.Slider2:setValue() Sets the value of the slider to the given one
comp.Slider2:setValue() Sets the default step for the slider

Class comp.TabWidget

comp.TabWidget:addSpace() Adds a space after the selected tab
comp.TabWidget:addTab() Adds tab at the end, uses indicator to display the tab
comp.TabWidget:addTabText() Adds tab at the end, uses text as indicator for the tab
comp.TabWidget:getCurrentTab() (deprecated) Use getCurrentTabIndex instead
comp.TabWidget:getCurrentTabIndex() Gets the tab index that is currently selected
comp.TabWidget:getIndicator() Gets the indicator component at the given index
comp.TabWidget:getNumTabs() Gets the numer of tabs
comp.TabWidget:getTab() Gets the tab at specified index
comp.TabWidget:insertTab() Inserts tab at given position, uses indicator to display the tab
comp.TabWidget:new(orientation) Creates a new tab widget with tabs on the given position
comp.TabWidget:onCurrentChanged(int) Called when the tab changes,
comp.TabWidget:setCurrentTab() Sets the tab that is currently selected
comp.TabWidget:setDeselectAllowed() Allow selecting no tab at all

Class comp.ProgressBar

comp.ProgressBar:getProgress() Gets the current progress
comp.ProgressBar:new() Creates a new progress bar
comp.ProgressBar:setColor() Sets the color of the progress bar
comp.ProgressBar:setProgress(The) Sets the current progress
comp.ProgressBar:setTask() Adds some text to the bar

Class comp.Chart

comp.Chart:addSeries() Adds a new data series to the graph
comp.Chart:clear() Clears all data from the graph
comp.Chart:new() Creates a new chart
comp.Chart:setColor() Sets the color of the bar
comp.Chart:setLineWidth() Sets the line with of the graph
comp.Chart:setSeriesLabels() Sets the labels for the series
comp.Chart:setType(type) Sets the type of graph

Class comp.ColorChooserButton

comp.ColorChooserButton:new() Creates a new color picker button.
comp.ColorChooserButton:onSelect(callback) Called when the color is selected
comp.ColorChooserButton:setColor() Sets the currently selected color.

Class comp.ColorPicker

comp.ColorPicker:new() Creates a new color picker
comp.ColorPicker:onColorChanged(callback) Called when the selected color changes
comp.ColorPicker:setColor() Sets the color of the color picker

Class comp.ColorChooser

comp.ColorChooser:new() Creates a new color chooser
comp.ColorChooser:onSelect(callback) Called when the color is selected.

Class comp.LineRenderView

comp.LineRenderView:addLine(from, to) Add a new displayed line from from to to
comp.LineRenderView:clear() Clear all lines added so far.
comp.LineRenderView:new() Creates a new line render component
comp.LineRenderView:setColor(color) Called to set the color of all lines added to this
comp.LineRenderView:setWidth(width) Set the width of all lines of the component.

Class comp.List

comp.List:addItem(item) Adds an item to the list
comp.List:clear(emitSignal) Clear items from list
comp.List:getItem(index) Returns component at position index
comp.List:getNumItems() Returns number of items in the list
comp.List:getSelectedIndex() Returns currently selected item
comp.List:new(drawBackground, orientation, autoDeselectDisabledItems) Creates a new list component
comp.List:onActivate(callback) Called when an item is activated
comp.List:onHover(callback) Called when an item is hovered on
comp.List:onSelect(callback) Called when an item is selected
comp.List:removeItem(index, emitSignal) Removes an item from the list
comp.List:select(index, emitSignal) Selects an item in the list
comp.List:setDeselectAllowed(deselectAllowed) Set policy to allow no selected item
comp.List:setEmitSignalOnReselect(emitSignal) Set policy not to emit a signal when the same item is selected

Class layout.ILayout

layout.ILayout:getItem() Get the item at the given index.
layout.ILayout:getNumItems() Get the number of items in a layout
layout.ILayout:removeItem() Removes an item from the layout, returns an object having ownership of the removed item.

Class layout.LayoutBase

layout.LayoutBase:addItem() Adds an item to the layout.
layout.LayoutBase:getComponent() Get the component stored in the layout.
layout.LayoutBase:insertItem() Adds an item to the layout at given position.
layout.LayoutBase:setGravity() Sets the alignment of the component.
layout.LayoutBase:setId() Sets a name for the layout.
layout.LayoutBase:setId() Sets a unique id for the layout.

Class layout.BoxLayout

layout.BoxLayout:new(orientation) Creates a new layout with the given orientation.

Class layout.AbsoluteLayout

layout.AbsoluteLayout:addItem() Adds an item with the given geometry to the layout.
layout.AbsoluteLayout:deleteAll() Removes all childs and deletes them.
layout.AbsoluteLayout:getIndex() Get the index of the item at given position.
layout.AbsoluteLayout:new(orientation) Creates a new layout with the given orientation.
layout.AbsoluteLayout:setItemPosition() [Deprecated] Sets item at position.
layout.AbsoluteLayout:setPosition() Sets the position of the item at given index at the given position.

Class layout.FloatingLayout

layout.FloatingLayout:addItem() Adds an item with the given alignments.
layout.FloatingLayout:deleteAll() Removes and deletes all elements in the layout.
layout.FloatingLayout:insertItem() Adds and items (and takes ownership), at the given position and with the given alignments.
layout.FloatingLayout:new() Creates a new layout
layout.FloatingLayout:setAlignment() Sets the alignment of the item at the position.


Tables

comp
Contains all UI components (widgets) and base classes.
layout
Contains all UI layouts and base classes.
util
Contains all util function for the UI.

Class util.Rect

A UI Rectangle.
util.Rect.h
Height of the rectangle
  • h int
util.Rect.w
Width of the rectangle
  • w int
util.Rect.x
Horizontal position of the upper left corner
  • x int
util.Rect.y
Vertical position of the upper left corner
  • y int
util.Rect:contains(x, y)
Checks if Rect contains the position on the screen.

Parameters:

  • x int x coordinate
  • y int y coordinate
util.Rect:intersects(other)
Checks if Rect intersects another Rect.

Parameters:

  • other Rect the other Rect
util.Rect:new(x, y, w, h)
Creates a new Rect. It can be called either empty or with all parameters.

Parameters:

  • x optional int x coordinate of the upper left corner
  • y optional int y coordinate of the upper left corner
  • w optional int width of the rectangle
  • h optional int height of the rectangle

Class util.MouseEvent

Represents a mouse event
util.MouseEvent.button
Mouse button related to the event: 0 = left, 1 = middle, 2 = right
  • button int
util.MouseEvent.type
Event type: 0 = mouse pressed, 1 = mouse released, 2 = mouse clicked, 3 = mouse enter, 4 = mouse exited, 5 = mouse moved, 6 = mouse wheel event, 7 = mouse double clicked
  • type int
util.MouseEvent.x
Horizontal position of the mouse when event was triggered
  • x int
util.MouseEvent.xrel
Relative horizontal position when event was triggered
  • xrel int
util.MouseEvent.y
Horizontal position of the mouse when event was triggered
  • y int
util.MouseEvent.yrel
Relative vertical position when event was triggered
  • yrel int

Class util.Size

A UI Size.
util.Alignment
Alignment of the layout item

Fields:

  • LEFT 0
  • CENTER 1
  • RIGHT 2
util.Orientation
Orientation of the layout item

Fields:

  • HORIZONTAL 0
  • VERTICAL 1
util.Size.h
Height of the size
  • h int
util.Size.h
Height of the size element
  • h int
util.Size.w
Width of the size element
  • w int
util.Size.w
Width of the size
  • w int
util.Size:new(w, h)
Creates a new Size

Parameters:

  • w int width of the size
  • h int height of the size
util.downcast(layout)
Properly set correct metatable of the object for most derived object

Parameters:

Returns:

    Object representing item, but with the most derived metatable

Class comp.ILayoutItem

The base abstract class to all layouts and components.

Internally, this is just a pointer to a C memory location. Since lua does not have a concept of ownership, a layout item is never owened by lua, and is just referenced by it.

The object might therefore become invalid if kept around. If you keep a layout item around, and you are not controlling the lifetime yourself, you can add a lifetime checker.

comp.ILayoutItem:addHighPriorityProcessingComponent()
Adds a component which will have priority in handling Input Actions
comp.ILayoutItem:destroy()
Destroys the item: the item cannot belong to a layout of component. This can not be used during a callback of the component itself or one of its children. To destroy a component from a callback, see util.destroyLater.
comp.ILayoutItem:getBeginFrameTimes()
Returns the rendering preparation time
comp.ILayoutItem:getEventTimes()
Returns the events processing time
comp.ILayoutItem:getId()
Obtains the id of the ui item.

Returns:

    string the id of the ui item.
comp.ILayoutItem:getRenderTimes()
Returns the rendering time
comp.ILayoutItem:getStepTimes()
Returns the gui update time
comp.ILayoutItem:getSwapTimes()
Returns the rendering finish time
comp.ILayoutItem:removeHighPriorityProcessingComponent()
Remove a component which was added via addHighPriorityProcessingComponent

Class comp.Component

A very simple UI component with basic functionality. Inherits all functions from comp.ILayoutItem.

Base class: comp.ILayoutItem.

comp.Component:addLifeTimeChecker()
Obtains an object from the component that can be used to check whether the component has been destroyed. Especially useful if you do not have control over the lifetime of the component and the component does not live for the entirety of the game.

You can keep around this object as long as you need.

Returns:

    LifeTimeChecker the object reference that can be used with api.gui.util.check(reference)
comp.Component:addStyleClass(class)
Assigns a style class to the component.

Parameters:

comp.Component:calcMinimumSize()
Gets minimum size taken by the component.

Returns:

    Size the minimum size that the component needs
comp.Component:getContentRect()
Gets Rect size for the component.

Returns:

    Rect the Rect representing the size of the component
comp.Component:getCore()
Returns the Core object for all Components

Returns:

    Core the core component
comp.Component:getLayout()
Returns layout of the component.

Returns:

    Layout the layout of the component
comp.Component:getName()
Receives the name of the component.

Returns:

    string the name of the component
comp.Component:getParent()
Gets parent of component (automatically downcasted).

Returns:

    Component the parent component
comp.Component:hasFocus()
Checks if component has focus.

Returns:

    bool true if the component has focus
comp.Component:insertMouseListener(func)
Prepends a mouse listener that will be called before all other listeners. Listeners can only be removed all at once

Parameters:

  • func bool (MouseEvent) callback The function to call when an event is triggered on the component

Returns:

    bool Whether the event was handled or not
comp.Component:invokeLater(callback)
Invoke a stored function at the beginning of the next frame.

Parameters:

  • callback func() A parameterless callback which will be invoked at the beginning of the next frame
comp.Component:isEnabled()
Checks if the object is interactable.

Returns:

    bool true if the object is interactable
comp.Component:isVisible()
Checks if the object is visible.

Returns:

    bool true if the object is visible
comp.Component:new(name, id)
Creates a new Component instance.

Parameters:

  • name string the name of the component (used for styles)
  • id string the id of the component

Returns:

    Component the new Component instance.
comp.Component:onDestroy(callback)
Adds a callback to be called when the item is destroyed.

Parameters:

  • callback func() the parameterless function called when the component is destroyed

Returns:

    type.Connection to disconnect the callback if no longer needed
comp.Component:onStep(callback)
Adds a callback to be called each gui update.

Parameters:

  • callback func(long,long) The function takes two numbers as input, specifying the frame time and the elapsed time

Returns:

    type.Connection to disconnect the callback if no longer needed
comp.Component:onVisibilityChange()
Adds a callback to be called when the visibility changes.

Returns:

    type.Connection to disconnect the callback if no longer needed
comp.Component:removeMouseListener()
Removes the mouse listener attached to the component.
comp.Component:removeStyleClass(class)
Removes a style class to the component.

Parameters:

  • class string Class to remove
comp.Component:setEnabled(enabled)
Makes the object (un)interactable.

Parameters:

  • enabled bool true if should be interactable
comp.Component:setFocus()
Sets a component to have focus.
comp.Component:setFocusable()
Enables/disable focus on this component
comp.Component:setGravity(horizontal, vertical)
Sets the alignment of the component. Both parameters can be set to 0.0 for left/top position, 0.5 for center positioning and 1.0 for right/bottom positioning. If set to -1, the element will grow in that dimension to fill up space.

Parameters:

  • horizontal float the horizontal gravity setting
  • vertical float the vertical gravity setting
comp.Component:setHighlighted(highlighted)
Sets highlighted.

Parameters:

  • highlighted bool true if the component should be highlighted (usually the yellow flashing)
comp.Component:setId(id)
Gives the component a unique identifier.

Parameters:

  • id string the id for the component
comp.Component:setInputActionBubbleUpAcceptFilter(a, whether)
Sets a handler for a list of input actions and decide whether to enable those input actions or not

Parameters:

  • a vector list of input actions
  • whether bool to enable or disable the provided list of input actions
comp.Component:setInputActionForward(sourceIa, targetComp, targetIa)
Forwards an input action to a target component with a specified source and target action.

Parameters:

  • sourceIa string The name of the source input action
  • targetComp Component The target component
  • targetIa string The name of the target input action
comp.Component:setInputActionHandler(ia, handlerFn, func)
Sets an handler for an input action, and another callback to determine whether it is enabled or not.

Parameters:

  • ia string The name of the input action
  • handlerFn func() A parameterless callback which will be invoked when the input action is triggered
  • func bool () enabledFn A parameterless callback returning "bool" deciding whether the input action is enabled
comp.Component:setLayout(layout)
Sets a layout (the component takes ownership of the layout).

Parameters:

  • layout Layout the layout that should be used for this component
comp.Component:setMaximumSize(size)
Set the maximum size that the components takes up.

Parameters:

  • size util.Size the maximum size that the component may reach
comp.Component:setMinimumSize(size)
Set the minimum size that the components takes up.

Parameters:

  • size util.Size the minimum size that the component may reach
comp.Component:setMouseListener(func)
Forwards mouse events to the component under the cursor. Listener is unique.

Parameters:

  • func bool (MouseEvent) callback The function to call when an event is triggered on the component

Returns:

    bool Whether the event was handled or not
comp.Component:setName(name)
Gives the component a name, used to apply styles.

Parameters:

  • name string the name for the component
comp.Component:setStyleClassList(list)
Assigns a style class to the component.

Parameters:

  • list {string,...} the list of style classes that should be added
comp.Component:setTooltip(text)
Sets the tooltip of the component.

Parameters:

  • text string the text that should be used for the tooltip
comp.Component:setTransparent(transparent)
Sets transparency.

Parameters:

  • transparent bool true if the component should be transparent
comp.Component:setVisible(visible, emitSignal)
Sets visibility.

Parameters:

  • visible bool true if component should be visible
  • emitSignal bool true if "onVisibilityChanged" callback should be called

Util

util.check(reference)
Checks if a component is still alive using the LifeTimeChecker.

Parameters:

  • reference LifeTimeChecker The lifetime checker reference for the component

Returns:

    bool true if the component is still alive.
util.destroyLater(comp)
Delete a gui element at the beginning of the next frame. The user must have obtained ownership of the item by removing from the layout.

Parameters:

util.getById(id)
Returns the component with the given id.

Parameters:

  • id string the id of the ui component with the given id

Returns:

    Component the component that was requested
util.getCommandTimes()
Returns commands processing time Available only within GUI State.

Returns:

    The commands processing time
util.getGameUI()
Returns the GameUI. Available only within GUI State.

Returns:

    Component the main game ui component
util.getInputMode()
Returns the current InputMode. Available only within GUI State.

Returns:

    The input mode
util.getMouseScreenPos()
Returns the screet coordinate at the mouse position.

Returns:

    type.Vec2i the vector containing the x and y coordinate of the mouse pointer on the screen
util.getReplicateTimes()
Returns the sync time between gui and simulation Available only within GUI State.

Returns:

    The sync time between gui and simulation
util.getStepTimes()
Returns the simulation update time Available only within GUI State.

Returns:

    The simulation update time

Class comp.Window

A special component with window-like behaviour.

Base class: comp.Component.

Available only within GUI State.

comp.Window:addHideOnCloseHandler()
Adds a default handler for "onClose" that hides the window when it is closed.

Without the callback, the close button does nothing.

comp.Window:close()
Closes the window. Calls the onClose callback.
comp.Window:getContent()
Returns the window content.

Returns:

    ILayoutItem the current content of the window
comp.Window:isAttached()
Checks if window is attached.

Returns:

    bool true if the window is attached
comp.Window:isPinnable()
Checks if window is pinnable.

Returns:

    bool true if the pin button is visible
comp.Window:isPinned()
Checks if window is pinned.

Returns:

    bool true if the window is pinned
comp.Window:maximize()
Maximizes the window to its maximisedSize size.

Must have set the maximisedSize with setMaximisedSize

comp.Window:minimize()
Minimizes the window to its minimizedSize size.

Must have set the maximisedSize with setMaximisedSize

comp.Window:new(title, content)
Creates a new Window.

Parameters:

  • title string the window title displayed in the top right corner
  • content Component the component that holds the content of the window

Returns:

    Window the window component
comp.Window:onClose(callback)
Adds a parameterless callback, which is called when the window is closed.

Parameters:

  • callback func() the callback function that should be called when close() is called
comp.Window:onMove(callback)
Adds a parameterless callback, which is called when the window is moved

Parameters:

  • callback func() the callback function that should be called when the window is moved
comp.Window:remove(win)
Removes a window from the UI and returns it.

Parameters:

  • win string the window to remove from the UI and return

Returns:

    Window the removed window
comp.Window:setAttached(b)
Sets the window to be attached.

Parameters:

  • b bool true if the window should get the :attached pseudoclass
comp.Window:setContent(content)
Sets the window content.

Parameters:

  • content ILayoutItem the component or layout that should be used as the window content
comp.Window:setIcon(icon)
Sets the window icon.

Parameters:

  • icon string the reference to the icon that should be set
comp.Window:setLocateButtonVisible(b)
Adds a button to follow entities and other objects.

Parameters:

  • b bool true if the locate button left to the title should be visible
comp.Window:setMaximiseSize()
Set the size when maximised.
comp.Window:setMovable(b)
Sets the window to be movable.

Parameters:

  • b bool true if the window should be movable
comp.Window:setPinButtonVisible(b)
Adds a button to pin the window. It automatically reflects the pin status of the window.

Parameters:

  • b bool true if the pin button right to the title should be visible
comp.Window:setPinned(b)
Sets the window to be pinned. Then the window is not closed when key is used.

Parameters:

  • b bool true if the window should be pinned
comp.Window:setPosition(x, y)
Sets the window position.

Parameters:

  • x int
  • y int
comp.Window:setResizable(b)
Sets the window to be resizable.

Parameters:

  • b bool true if the window should be resizable
comp.Window:setSize(size)
Sets the window size.

Parameters:

comp.Window:setTitle(title)
Sets the window title.

Parameters:

  • title string the title that should be set

Class comp.GameUI

A special component which is the root of many other in-game components, including the entire ingame menu and the windowing system. In particular, it displays the main 3d representation of the world, in the form of a RendererComponent.

Base class: comp.Component.

Available only within GUI State.

comp.GameUI:getMainRenderComponent()
Obtains the main 3d scene.

Returns:

    RenderComponent the main render component for the game world
comp.GameUI:getViewManager()
Obtains the view manager.

Returns:

    ViewManager the view manager for entity windows
comp.GameUI:playCutscene(fileName)
Plays a cutscene.

Parameters:

  • fileName string the reference to the cutscene keyframe definition that should be played
comp.GameUI:playSoundEffect(name)
Plays a single sound effect.

Parameters:

  • name string the name of the sound effect
comp.GameUI:playTrack(filename, offset)
Plays a single track with the music player.

Parameters:

  • filename string the reference to the soundtrack file that should be played
  • offset float the start position of the track
comp.GameUI:setConstructionAngle(angle)
Sets the default construction angle for constructions.

Parameters:

  • angle float the default construction angle

Class comp.RendererComponent

Contains the 3d scene and control most actions.

Base class: comp.Component.

Available only within GUI State.

comp.RendererComponent:getCameraController()
Gets the camera controller for the component.

Returns:

    CameraController the camera controller of the RendererComponent
comp.RendererComponent:getTerrainPos()
Gets the terrain position pointed by the mouse.

Returns:

    {float,float,float} x, y and z coordinates of the terrain position
comp.RendererComponent:stopAction()
Stops the current Action (bulldoze, build construction, etc.)

Class util.CameraController

Controls the camera view.

Available only within GUI State.

util.CameraController:focus(entity)
Focuses the camera on an entity.

Parameters:

  • entity Entity the id of the entity that should be focussed on
util.CameraController:follow(entity, jump)
Sets camera to follow an Entity.

Parameters:

  • entity Entity the id of the entity that should be followed
  • jump bool true if the camera should directly jump to the entity and not slide there
util.CameraController:getCameraData()
Obtains the current camera data.

Returns:

    type.Vec5f the current camera data
util.CameraController:getFollowEntity()
Gets the entity currently being followed.
util.CameraController:setCameraData(center, dist, angle, pitch)
Sets the camera data with custom position and other information.

Parameters:

  • center type.Vec2f position on the map where the camera should point
  • dist float the distance from this position
  • angle float the rotation angle
  • pitch float the pitch angle

Class util.ViewManager

Controls the small entity windows.

Available only within GUI State.

util.ViewManager:closeAll()
Closes all currently open entity windows.
util.ViewManager:openWindow(entity, above, tabIndex)
Focuses the camera on an entity.

Parameters:

  • entity Entity the id of the entity of which to open the window
  • above bool whether the window should go on top
  • tabIndex int the tab index on which to open the window

Returns:

    Window the opened window or nil

Class comp.TextInputField

A simple component for input of lines of text.

Base class: comp.Component

comp.TextInputField:OnFocusChange(callback)
Sets a callback that is called when the focus changes.

Parameters:

  • callback func Function taking a boolean telling if focus was lost or gained.
comp.TextInputField:getSelectedText()
Gets selected text.
comp.TextInputField:getText()
Returns the text in the input field.
comp.TextInputField:new()
Creates a new text input field with placeholder text.
comp.TextInputField:onCancel(callback)
Sets a callback that is called when enter is pressed.

Parameters:

  • callback func Function.
comp.TextInputField:onChange(callback)
Sets a callback that is called when the text changes.

Parameters:

  • callback func Function with the new text.
comp.TextInputField:onEnter(callback)
Sets a callback that is called when enter is pressed.

Parameters:

  • callback func Function.
comp.TextInputField:selectAll()
Selects entire text
comp.TextInputField:setDeselectOnFocusLost()
Clear selection when focus is lost
comp.TextInputField:setMaxLength()
Sets the maximal length of the input text.
comp.TextInputField:setText()
Sets the text of the field to the given text.

Class comp.TextView

A simple component for displaying (large amounts) of text.

Base class: comp.Component

comp.TextView:getSelectedText()
Gets selected text.
comp.TextView:getText()
Gets the entire text.
comp.TextView:getTextAlignment()
Gets the alignment of the text
comp.TextView:getTextAlignment2()
Gets the alignment of the text

Returns:

    { horizontal, vertical }
comp.TextView:new()
Creates a new text view with some text.
comp.TextView:setSelectable()
Sets the text as selectable.
comp.TextView:setText()
Sets the text
comp.TextView:setTextAlignment()
Sets the alignment of the text

Class comp.CheckBox

A simple component for displaying (large amounts) of text.

Base class: comp.Component.

comp.CheckBox:isSelected()
Return selection status for the checkbox
comp.CheckBox:new()
Gets the entire text.
comp.CheckBox:onToggle(callback)
Sets a callback that is called when the checkbox is selected

Parameters:

  • callback func Function taking a boolean telling if box was selected or unselected.
comp.CheckBox:setSelected(value, emit)
Sets the checkbox as selected.

Parameters:

  • value bool Whether the box is selected or not
  • emit bool Signal When true, "onToggle" will be called
comp.CheckBox:setText()
Sets the label text of the checkbox.

Class comp.ImageView

A simple component for displaying images.

Base class: comp.Component.

comp.ImageView:setImage()
Sets the image of the image view.
comp.ImageView:setText()
Creates a new imageview with a texture.

Class comp.ContentView

The base classes for components containing a single component.

Base class: comp.Component.

comp.ContentView:getContent()
Returns the content
comp.ContentView:setContent()
Sets the content (takes ownership of content)
comp.ContentView:setContentAlignment()
Sets the alignment of the content

Class comp.ToggleButton

A simple button that can be toggled on and off.

Base class: comp.ContentView.

comp.ToggleButton:isSelected()
TReturns whether the toggle button is toggled
comp.ToggleButton:new(child)
Creates a toggle button with a child element.

Parameters:

comp.ToggleButton:onToggle()
Calls the callback when the button is toggled
comp.ToggleButton:setSelected()
TReturns whether the toggle status of the button
comp.ToggleButton:toggle()
TToggles the button

Class comp.Button

A simple button that can be clicked and triggers an event.

Base class: comp.ContentView.

comp.Button:click()
Triggers a button click
comp.Button:new(child, clickOnPress)
Creates a button with a child element.

Parameters:

  • child ILayoutItem The content of the button
  • clickOnPress bool Whether the button tirggers a "onClick" callback when released, instead as when pressed
comp.Button:onClick()
Calls the callback when the button is clicked

Class comp.ToggleButtonGroup

A group of buttons that can be toggled exclusively.

Base class: comp.Component.

comp.ToggleButtonGroup:add()
Adds a new toggle button to the group, takes ownership of the button
comp.ToggleButtonGroup:getButton()
Returns a button with the given index
comp.ToggleButtonGroup:getNumButtons()
Returns the number of buttons
comp.ToggleButtonGroup:getSelectedIndex()
Returns the index of the selected button
comp.ToggleButtonGroup:new()
Creates a toggle button group.
comp.ToggleButtonGroup:onCurrentIndexChanged()
Calls the callback when one button is toggled with the index of the button
comp.ToggleButtonGroup:setEmitSignal()
Sets the group to trigger a signal when pressed
comp.ToggleButtonGroup:setOneButtonMustAlwaysBeSelected()
Prevents deselecting all buttons

Class comp.Table

Creates a simple table which supports selection and has an header.

Base class: comp.Component.

comp.Table:addRow(components)
Adds a new row of components

Parameters:

  • components {gui.comp.Component,...} Header components
comp.Table:deleteAll()
Remove all rows and all components
comp.Table:deleteRows()
Remove all rows between first and last
comp.Table:getNumCols()
Gets the number of columns of the table
comp.Table:getNumRows()
Gets the number of rows of the cable
comp.Table:insertRow(components)
Adds a new row of components at the given index

Parameters:

  • components {gui.comp.Component,...} Header components
comp.Table:new(numColumns, selectable)
Create a new table with a set number of columns and an optional selection policy.

Parameters:

  • numColumns string number of columns
  • selectable string one of "NONE", "SELECTABLE" or "MULTI".
comp.Table:setColWeight()
Sets the column weight (affects the width)
comp.Table:setColWidth()
Set the column default width.
comp.Table:setHeader(components)
Sets the header for the table

Parameters:

  • components {gui.comp.Component,...} Header components
comp.Table:setMaxColWidth()
Sets the column maximum width
comp.Table:setMinColWidth()
Sets the column minimum width
comp.Table:setNumCols()
Sets the number of columns.
comp.Table:setOrder()
Sort the rows with a given order.

Class comp.ScrollArea

Creates an area with (optional) scrollbar to fit bigger components.

Base class: comp.Component.

comp.ScrollArea:SetHorizontalScrollBarPolicy(policy)
Sets the policy for the horizontal scrollbar

Parameters:

comp.ScrollArea:ensureVisible()
Ensures a child component is visible
comp.ScrollArea:getContent()
Returns content of the scroll area.
comp.ScrollArea:getScrollOffset()
Returns current scroll offset.
comp.ScrollArea:getViewportRect()
Return the Rect of the visible portion
comp.ScrollArea:new()
Makes a new scroll area with given component and names.
comp.ScrollArea:onScroll()
Sets a callback for scrolling
comp.ScrollArea:setContent()
Sets the content of the scroll area
comp.ScrollArea:setScrollOffset()
Scrolls to given position.
comp.ScrollArea:setVerticalScrollBarPolicy(policy)
Sets the policy for the vertical scrollbar

Parameters:

comp.ScrollBarPolicy
The visibility policy for the ScrollBar

Fields:

  • AS_NEEDED 0
  • ALWAYS_OFF 1
  • ALWAYS_ON 2
  • SIMPLE 3

Class comp.ComboBox

A combo box with dropdown menu for selecting entries.

Base class: comp.Component.

comp.ComboBox:addItem()
Adds a new item at the bottom of the combo box
comp.ComboBox:addItemFactory(callback)
Adds a new component at the bottom of the combo box, callback is called each time the combbox is open

Parameters:

  • callback func A function returning a new Component
comp.ComboBox:clear()
Remove all entries from the combo box
comp.ComboBox:getCurrentIndex()
Gets currently selected index.
comp.ComboBox:getNumItems()
Returns the number of items in a layout.
comp.ComboBox:new()
Makes a new empty combo box.
comp.ComboBox:onIndexChanged(callback)
Add callback that is called when the current index changes.

Parameters:

  • callback func(int) Function to be called

Class comp.DoubleSpinBox

A spin box with input for floating point numbers.

Base class: comp.Component

comp.DoubleSpinBox:getMaximum()
Returns the current maximum possible value for the spinbox
comp.DoubleSpinBox:getMinimum()
Returns the current minimum possible value for the spinbox
comp.DoubleSpinBox:getValue()
Returns the current value of the spinbox
comp.DoubleSpinBox:new()
Makes a new spin box with default values.
comp.DoubleSpinBox:onChange(callback)
Adds a callback for when the spinbox changes value.

Parameters:

  • callback func(number) called each time the spinbox changes value
comp.DoubleSpinBox:setMaximum()
Sets maximum selectable value for the spin box
comp.DoubleSpinBox:setMinimum()
Sets minimum selectable value for the spin box
comp.DoubleSpinBox:setStep()
Sets the interval between values of the spinbox
comp.DoubleSpinBox:setValue()
Sets the current value of the spinbox

Class comp.SpinBox

A spin box with input for whole numbers.

Base class: comp.Component

comp.SpinBox:getValue()
Returns the current value of the spinbox
comp.SpinBox:new()
Makes a new spin box with default values.
comp.SpinBox:onChange(callback)
Adds a callback for when the spinbox changes value.

Parameters:

  • callback func(number) called each time the spinbox changes value
comp.SpinBox:setRange()
Sets minimum and maximum selectable values for the spin box
comp.SpinBox:setValue()
Sets the current value of the spinbox

Class comp.AbstractSlider

A base abstract class for all slider types

Base class: comp.Component

comp.AbstractSlider:getPageStep()
Gets the current page step of the slider
comp.AbstractSlider:getPageStep()
Gets the current minimum value of the slider
comp.AbstractSlider:getPageStep()
Gets the current maximum value of the slider
comp.AbstractSlider:getStep()
Gets the current step of the slider
comp.AbstractSlider:getValue()
Sets the current value of the slider
comp.AbstractSlider:onValueChanged()
Get called when the slider value changes.
comp.AbstractSlider:setDefaultValue()
Sets the default value of the slider
comp.AbstractSlider:setMaximum()
Sets the maximum value of the slider
comp.AbstractSlider:setMinimum()
Sets the minimum size of the slider
comp.AbstractSlider:setPageStep()
Sets the big increment size of the slider (controlled with page buttons)
comp.AbstractSlider:setStep()
Sets the increment size of the slider
comp.AbstractSlider:setValue()
Sets the value of the slider

Class comp.Slider

An slider that can be vertical of horizontal.

Base class: comp.AbstractSlider

comp.Slider:new()
Creates a new vertical or horizontal slider

Class comp.Slider2

A 2d slider with 2 sets of values

Base class: comp.Component

comp.Slider2:getValue()
Sets the current value of the slider
comp.Slider2:new()
Creates a new 2d slider
comp.Slider2:onValueChanged(callback)
Adds a callback for the slider, that is called when the slider value changes

Parameters:

  • callback func(type.Vec2i) called when the value changes
comp.Slider2:setMaximum()
Sets the maximum value for the slider
comp.Slider2:setMinimum()
Sets the minimum value for the slider
comp.Slider2:setValue()
Sets the default value for the slider
comp.Slider2:setValue()
Sets the value of the slider to the given one
comp.Slider2:setValue()
Sets the default step for the slider

Class comp.TabWidget

A component with multiple tabs to diplay the content.

Base class: comp.Component

comp.TabWidget:addSpace()
Adds a space after the selected tab
comp.TabWidget:addTab()
Adds tab at the end, uses indicator to display the tab
comp.TabWidget:addTabText()
Adds tab at the end, uses text as indicator for the tab
comp.TabWidget:getCurrentTab()
(deprecated) Use getCurrentTabIndex instead
comp.TabWidget:getCurrentTabIndex()
Gets the tab index that is currently selected
comp.TabWidget:getIndicator()
Gets the indicator component at the given index
comp.TabWidget:getNumTabs()
Gets the numer of tabs
comp.TabWidget:getTab()
Gets the tab at specified index
comp.TabWidget:insertTab()
Inserts tab at given position, uses indicator to display the tab
comp.TabWidget:new(orientation)
Creates a new tab widget with tabs on the given position

Parameters:

  • orientation string One of "NORTH", "EAST", "SOUTH", "WEST"
comp.TabWidget:onCurrentChanged(int)
Called when the tab changes,

Parameters:

  • int func(int, ) callback Will be provided an index before and after the call
comp.TabWidget:setCurrentTab()
Sets the tab that is currently selected
comp.TabWidget:setDeselectAllowed()
Allow selecting no tab at all

Class comp.ProgressBar

A component that displays a progress

Base class: comp.Component

comp.ProgressBar:getProgress()
Gets the current progress
comp.ProgressBar:new()
Creates a new progress bar
comp.ProgressBar:setColor()
Sets the color of the progress bar
comp.ProgressBar:setProgress(The)
Sets the current progress

Parameters:

  • The number progress (between 0 and 1)
comp.ProgressBar:setTask()
Adds some text to the bar

Class comp.Chart

A line or bar plot of values on a graph Base class: comp.Component
comp.Chart:addSeries()
Adds a new data series to the graph
comp.Chart:clear()
Clears all data from the graph
comp.Chart:new()
Creates a new chart
comp.Chart:setColor()
Sets the color of the bar
comp.Chart:setLineWidth()
Sets the line with of the graph
comp.Chart:setSeriesLabels()
Sets the labels for the series
comp.Chart:setType(type)
Sets the type of graph

Parameters:

  • type string One of "LINE", "LINE_STEP" or "BAR"

Class comp.ColorChooserButton

A button that opens a color picker Base class: comp.Component
comp.ColorChooserButton:new()
Creates a new color picker button. The reset color is type.Vec3f(-1, -1, -1).
comp.ColorChooserButton:onSelect(callback)
Called when the color is selected

Parameters:

  • callback func(type.Vec3f) The callback that is called
comp.ColorChooserButton:setColor()
Sets the currently selected color.

Class comp.ColorPicker

A color picker component Base class: comp.Component
comp.ColorPicker:new()
Creates a new color picker
comp.ColorPicker:onColorChanged(callback)
Called when the selected color changes

Parameters:

  • callback func(type.Vec3f) The callback that is called
comp.ColorPicker:setColor()
Sets the color of the color picker

Class comp.ColorChooser

A color chooser component Base class: comp.Component
comp.ColorChooser:new()
Creates a new color chooser
comp.ColorChooser:onSelect(callback)
Called when the color is selected.

Parameters:

  • callback func(type.Vec3f) The callback that is called

Class comp.LineRenderView

Display lines Base class: comp.Component
comp.LineRenderView:addLine(from, to)
Add a new displayed line from from to to

Parameters:

comp.LineRenderView:clear()
Clear all lines added so far.
comp.LineRenderView:new()
Creates a new line render component
comp.LineRenderView:setColor(color)
Called to set the color of all lines added to this

Parameters:

comp.LineRenderView:setWidth(width)
Set the width of all lines of the component.

Parameters:

  • width number Width, in pixels

Class comp.List

A list of components with automatic scroll area Base class: comp.ScrollArea
comp.List:addItem(item)
Adds an item to the list

Parameters:

  • item type.Component The item to add
comp.List:clear(emitSignal)
Clear items from list

Parameters:

  • emitSignal bool
comp.List:getItem(index)
Returns component at position index

Parameters:

  • index number

Returns:

    type.Component Item at position index
comp.List:getNumItems()
Returns number of items in the list

Returns:

    int Number of items
comp.List:getSelectedIndex()
Returns currently selected item

Returns:

    int Currently selected index
comp.List:new(drawBackground, orientation, autoDeselectDisabledItems)
Creates a new list component

Parameters:

  • drawBackground bool
  • orientation Orientation
  • autoDeselectDisabledItems bool
comp.List:onActivate(callback)
Called when an item is activated

Parameters:

  • callback func(number) The callback that is called

Returns:

    type.Connection A connection that needs to be disconnected when the callback should be removed
comp.List:onHover(callback)
Called when an item is hovered on

Parameters:

  • callback func(number) The callback that is called

Returns:

    type.Connection A connection that needs to be disconnected when the callback should be removed
comp.List:onSelect(callback)
Called when an item is selected

Parameters:

  • callback func(number) The callback that is called

Returns:

    type.Connection A connection that needs to be disconnected when the callback should be removed
comp.List:removeItem(index, emitSignal)
Removes an item from the list

Parameters:

  • index int The index of the item to remove
  • emitSignal bool Emit select signal for newly selected item

Returns:

    type.ILayoutItem item the removed item
comp.List:select(index, emitSignal)
Selects an item in the list

Parameters:

  • index int
  • emitSignal bool
comp.List:setDeselectAllowed(deselectAllowed)
Set policy to allow no selected item

Parameters:

  • deselectAllowed bool
comp.List:setEmitSignalOnReselect(emitSignal)
Set policy not to emit a signal when the same item is selected

Parameters:

  • emitSignal bool

Class layout.ILayout

Base for all layouts, cannot be created and is used only as base class.

Base class: comp.ILayoutItem.

layout.ILayout:getItem()
Get the item at the given index.
layout.ILayout:getNumItems()
Get the number of items in a layout
layout.ILayout:removeItem()
Removes an item from the layout, returns an object having ownership of the removed item.

Class layout.LayoutBase

Abstract layout with an id. Cannot be created and is used only as base class.

Base class: layout.ILayout.

layout.LayoutBase:addItem()
Adds an item to the layout. Gives ownership to the layout.
layout.LayoutBase:getComponent()
Get the component stored in the layout.
layout.LayoutBase:insertItem()
Adds an item to the layout at given position. Gives ownership to the layout.
layout.LayoutBase:setGravity()
Sets the alignment of the component.
layout.LayoutBase:setId()
Sets a name for the layout.
layout.LayoutBase:setId()
Sets a unique id for the layout.

Class layout.BoxLayout

A layout that aligns it's childs in a stack.

Base class: layout.AbstractLayout.

layout.BoxLayout:new(orientation)
Creates a new layout with the given orientation.

Parameters:

  • orientation string One of "HORIZONTAL" or "VERTICAL".

Class layout.AbsoluteLayout

A layout that aligns it childs with an absolute position, independently of other siblings. Each item has an absolute position relative to the parent.

Base class: layout.LayoutBase.

layout.AbsoluteLayout:addItem()
Adds an item with the given geometry to the layout. Takes ownership of the item.
layout.AbsoluteLayout:deleteAll()
Removes all childs and deletes them.
layout.AbsoluteLayout:getIndex()
Get the index of the item at given position.
layout.AbsoluteLayout:new(orientation)
Creates a new layout with the given orientation.

Parameters:

  • orientation string One of "HORIZONTAL" or "VERTICAL".
layout.AbsoluteLayout:setItemPosition()
[Deprecated] Sets item at position. Use setPosition instead.
layout.AbsoluteLayout:setPosition()
Sets the position of the item at given index at the given position.

Class layout.FloatingLayout

A layout that aligns it's childs if a position that is relative to the parent.

Base class: layout.LayoutBase.

layout.FloatingLayout:addItem()
Adds an item with the given alignments.
layout.FloatingLayout:deleteAll()
Removes and deletes all elements in the layout.
layout.FloatingLayout:insertItem()
Adds and items (and takes ownership), at the given position and with the given alignments.
layout.FloatingLayout:new()
Creates a new layout
layout.FloatingLayout:setAlignment()
Sets the alignment of the item at the position.
generated by LDoc 1.4.3 Last updated 2023-04-18 15:10:38