Controls
Every control you can add to a window, a page, a section, a row or an overlay.
WaxContainer
Something controls can be added to: a window, a page, a section, a row or an overlay.
Below, container stands for one of these.
container:Label(content, options?)
Adds text that wraps to the container's width.
container:Label(content: any, options?: WaxLabelOptions): WaxLabel| Parameter | Type |
|---|---|
content | any |
options (optional) | WaxLabelOptions |
Returns WaxLabel
container:Heading(content)
Adds a bold title line.
container:Heading(content: any): WaxHeading| Parameter | Type |
|---|---|
content | any |
Returns WaxHeading
container:Separator()
Adds a thin dividing line.
container:Separator(): WaxControlReturns WaxControl
container:Spacer(height?)
Adds an empty gap, as tall as the theme's spacing when no height is given.
container:Spacer(height?: number): WaxControl| Parameter | Type |
|---|---|
height (optional) | number |
Returns WaxControl
container:Button(caption?, on_click?, options?)
Adds a button. on_click runs on each click. With an icon and no caption it is an icon button.
container:Button(caption?: string, on_click?: fun(), options?: WaxButtonOptions): WaxButton| Parameter | Type |
|---|---|
caption (optional) | string |
on_click (optional) | fun() |
options (optional) | WaxButtonOptions |
Returns WaxButton
container:Icon(name, options?)
Adds an icon on its own, by name. The menu's Icons page lists the names.
container:Icon(name: string, options?: WaxIconOptions): WaxIcon| Parameter | Type |
|---|---|
name | string |
options (optional) | WaxIconOptions |
Returns WaxIcon
container:Toggle(caption, initial?, on_change?)
Adds a switch. on_change(on) runs when the user flips it.
container:Toggle(caption: string, initial?: boolean, on_change?: fun(on: boolean)): WaxToggle| Parameter | Type |
|---|---|
caption | string |
initial (optional) | boolean |
on_change (optional) | fun(on: boolean) |
Returns WaxToggle
container:Slider(caption, options?, on_change?)
Adds a slider with a read-out. on_change(value) runs while the user drags it.
container:Slider(caption: string, options?: WaxSliderOptions, on_change?: fun(value: number)): WaxSlider| Parameter | Type |
|---|---|
caption | string |
options (optional) | WaxSliderOptions |
on_change (optional) | fun(value: number) |
Returns WaxSlider
container:Input(caption?, options?, on_commit?)
Adds a text box. on_commit(text) runs when Enter is pressed or the box loses focus.
container:Input(caption?: string, options?: WaxInputOptions, on_commit?: fun(text: string)): WaxInput| Parameter | Type |
|---|---|
caption (optional) | string |
options (optional) | WaxInputOptions |
on_commit (optional) | fun(text: string) |
Returns WaxInput
container:Dropdown(caption, choices, selected?, on_change?)
Adds a dropdown that opens in place. on_change(choice) runs when the user picks one.
container:Dropdown<T>(caption: string, choices: T[], selected?: T, on_change?: fun(choice: T)): WaxDropdown| Parameter | Type | Description |
|---|---|---|
caption | string | |
choices | T[] | |
selected (optional) | T | The first choice when omitted. |
on_change (optional) | fun(choice: T) |
Returns WaxDropdown
container:Section(title, options?)
Adds a collapsible card and returns it as a container: section:Button(...), section:Toggle(...) and so on.
container:Section(title: string, options?: WaxSectionOptions): WaxSection| Parameter | Type |
|---|---|
title | string |
options (optional) | WaxSectionOptions |
Returns WaxSection
container:Title(content, description?)
Adds a title for a page or a group of controls: large text, an optional explanation, and a rule under it.
container:Title(content: string, description?: string): WaxTitle| Parameter | Type |
|---|---|
content | string |
description (optional) | string |
Returns WaxTitle
container:Row()
Adds a row. Controls added to the returned container sit side by side and share the width.
container:Row(): WaxRowReturns WaxRow
container:Color(caption, color?, on_change?)
A colour the user can change.
container:Color(caption: string, color?: string, on_change?: fun(color: string)): WaxColorControl| Parameter | Type | Description |
|---|---|---|
caption | string | |
color (optional) | string | "#rrggbb". White when omitted. |
on_change (optional) | fun(color: string) |
Returns WaxColorControl
container:Grid(options)
Adds a grid for any number of items. It builds only the cells in view, with the make and show functions in options.
container:Grid(options: WaxGridOptions): WaxGrid| Parameter | Type |
|---|---|
options | WaxGridOptions |
Returns WaxGrid
container:Flow(options?)
Adds an area where controls keep their own size and wrap onto new lines. Add them to the returned container.
container:Flow(options?: WaxFlowOptions): WaxRow| Parameter | Type |
|---|---|
options (optional) | WaxFlowOptions |
Returns WaxRow
container:Progress(caption, value?, options?)
Adds a progress bar. value is 0..1.
container:Progress(caption: string, value?: number, options?: WaxProgressOptions): WaxProgress| Parameter | Type |
|---|---|
caption | string |
value (optional) | number |
options (optional) | WaxProgressOptions |
Returns WaxProgress
container:Field(name, value?, options?)
Adds a name with a value on the right, for read-outs.
container:Field(name: string, value?: any, options?: WaxFieldOptions): WaxField| Parameter | Type |
|---|---|
name | string |
value (optional) | any |
options (optional) | WaxFieldOptions |
Returns WaxField
container:Keybind(caption, key?, on_change?)
Adds a key the user can rebind by clicking it and pressing a key. on_change(key) gets the engine's key name.
container:Keybind(caption: string, key?: string, on_change?: fun(key: string)): WaxKeybind| Parameter | Type |
|---|---|
caption | string |
key (optional) | string |
on_change (optional) | fun(key: string) |
Returns WaxKeybind
container:Console(options?)
Adds a scrolling list of text lines, such as a log.
container:Console(options?: WaxConsoleOptions): WaxConsole| Parameter | Type |
|---|---|
options (optional) | WaxConsoleOptions |
Returns WaxConsole
WaxControl
What every control has.
You get one from container:Separator, container:Spacer. Below, control stands for one of these.
| Signal | Handler receives | Description |
|---|---|---|
Changed | depends on the control | Fires when the user changes the control's value. |
control:Destroy()
Removes the control.
control:Destroy()Returns nothing.
control:SetVisible(shown)
Shows or hides the control. A hidden control takes no room.
control:SetVisible(shown: boolean)| Parameter | Type |
|---|---|
shown | boolean |
Returns nothing.
control:SetEnabled(enabled)
Greys the control out and stops it reacting, or makes it usable again.
control:SetEnabled(enabled: boolean)| Parameter | Type |
|---|---|
enabled | boolean |
Returns nothing.
WaxLabel
It can also do everything WaxControl can. You get one from container:Label. Below, label stands for one of these.
label:Set(value)
Replaces the text.
label:Set(value: any)| Parameter | Type |
|---|---|
value | any |
Returns nothing.
label:SetColor(color)
Changes the text colour.
label:SetColor(color: WaxColor)| Parameter | Type |
|---|---|
color | WaxColor |
Returns nothing.
WaxHeading
It can also do everything WaxControl can. You get one from container:Heading. Below, heading stands for one of these.
heading:Set(value)
Replaces the text.
heading:Set(value: any)| Parameter | Type |
|---|---|
value | any |
Returns nothing.
WaxButton
It can also do everything WaxControl can. You get one from container:Button. Below, button stands for one of these.
| Signal | Handler receives | Description |
|---|---|---|
Activated | nothing | Fires on each click, after on_click. |
Changed | nothing | The same signal as Activated. |
button:SetIcon(name)
Shows another icon on a button that was made with one.
button:SetIcon(name: string)| Parameter | Type |
|---|---|
name | string |
Returns nothing.
button:Spin()
Turns the icon round once.
button:Spin()Returns nothing.
WaxIcon
It can also do everything WaxControl can. You get one from container:Icon. Below, icon stands for one of these.
icon:Set(name)
Shows another icon.
icon:Set(name: string)| Parameter | Type |
|---|---|
name | string |
Returns nothing.
WaxToggle
It can also do everything WaxControl can. You get one from container:Toggle. Below, toggle stands for one of these.
| Signal | Handler receives | Description |
|---|---|---|
Changed | on: boolean | Fires when the user flips the switch. |
toggle:Get()
True while the switch is on.
toggle:Get(): booleanReturns boolean
toggle:Set(on, instant?)
Turns the switch on or off without firing Changed.
toggle:Set(on: boolean, instant?: boolean)| Parameter | Type | Description |
|---|---|---|
on | boolean | |
instant (optional) | boolean | True skips the sliding animation, for a switch that is being reused for another row. |
Returns nothing.
toggle:SetCaption(text)
Changes the text beside the switch.
toggle:SetCaption(text: string)| Parameter | Type |
|---|---|
text | string |
Returns nothing.
WaxColorControl
A colour selector. It opens a panel with a shade box, a hue bar and the colour as text that can be typed, pasted or copied.
It can also do everything WaxControl can. You get one from container:Color. Below, colorControl stands for one of these.
| Signal | Handler receives | Description |
|---|---|---|
Changed | color: string | Fires with "#rrggbb" on every change, also while the mouse is held. |
Released | color: string | Fires once when the user lets go, or commits a typed colour. Use it for saving. |
colorControl:Get()
The colour as "#rrggbb".
colorControl:Get(): stringReturns string
colorControl:Set(color)
Sets the colour without firing Changed.
colorControl:Set(color: string)| Parameter | Type | Description |
|---|---|---|
color | string | "#rrggbb" |
Returns nothing.
WaxTitle
A page or group title: large text, an optional line under it, and a rule.
It can also do everything WaxControl can. You get one from container:Title. Below, title stands for one of these.
title:Set(content)
Changes the title text.
title:Set(content: any)| Parameter | Type |
|---|---|
content | any |
Returns nothing.
title:SetDescription(description)
Changes the line under the title (only if the title was made with one).
title:SetDescription(description: any)| Parameter | Type |
|---|---|
description | any |
Returns nothing.
WaxSlider
A slider. The number beside it can be clicked and typed into.
It can also do everything WaxControl can. You get one from container:Slider. Below, slider stands for one of these.
| Signal | Handler receives | Description |
|---|---|---|
Changed | value: number | Fires with each new value while the user drags (once, on letting go, with live = false), and when a number is typed. |
Released | value: number | Fires once when the user lets go, for changes too heavy to apply during the drag. |
slider:Get()
The current value.
slider:Get(): numberReturns number
slider:Set(value)
Moves the slider (snapped and kept within its range) without firing Changed.
slider:Set(value: number)| Parameter | Type |
|---|---|
value | number |
Returns nothing.
WaxInput
It can also do everything WaxControl can. You get one from container:Input. Below, input stands for one of these.
| Signal | Handler receives | Description |
|---|---|---|
Changed | text: string | Fires when the text is committed (Enter, or the box losing focus). |
Entered | text: string | Fires only when Enter is pressed, even when the text is the same as last time (for a command line). |
Typed | text: string | Fires on every change to the text while typing. |
input:Get()
The text in the box.
input:Get(): stringReturns string
input:Focus()
Gives the box the keyboard, so the user can type without clicking it.
input:Focus()Returns nothing.
input:HasFocus()
True while the box has the keyboard.
input:HasFocus(): booleanReturns boolean
input:SetGhost(text)
Shows greyed text after what is typed, such as the rest of a suggested word. Only a box made with mono = true shows it.
input:SetGhost(text: string)| Parameter | Type | Description |
|---|---|---|
text | string | Empty to show nothing. |
Returns nothing.
input:Set(text)
Replaces the text without firing Changed.
input:Set(text: any)| Parameter | Type |
|---|---|
text | any |
Returns nothing.
WaxDropdown
A dropdown opens in place under its header. The chosen row is highlighted, and only one list is open at a time.
It can also do everything WaxControl can. You get one from container:Dropdown. Below, dropdown stands for one of these.
| Signal | Handler receives | Description |
|---|---|---|
Changed | choice: any | Fires when the user picks a choice. |
dropdown:Get()
The selected choice.
dropdown:Get(): anyReturns any
dropdown:Set(choice)
Selects a choice without firing Changed.
dropdown:Set(choice: any)| Parameter | Type |
|---|---|
choice | any |
Returns nothing.
WaxSection
A collapsible card. It is a container for controls.
It can also do everything WaxContainer can. You get one from container:Section. Below, section stands for one of these.
| Property | Type | Description |
|---|---|---|
control | WaxControl | The card itself, for Destroy, SetVisible and SetEnabled. |
section:SetOpen(open)
Expands or collapses the section.
section:SetOpen(open: boolean)| Parameter | Type |
|---|---|
open | boolean |
Returns nothing.
section:IsOpen()
True while the section is expanded.
section:IsOpen(): booleanReturns boolean
WaxRow
A container whose controls sit side by side.
It can also do everything WaxContainer can. You get one from container:Row, container:Flow.
| Property | Type | Description |
|---|---|---|
control | WaxControl | The row itself, for Destroy, SetVisible and SetEnabled. |
WaxProgress
It can also do everything WaxControl can. You get one from container:Progress. Below, progress stands for one of these.
progress:Get()
The current value, 0..1.
progress:Get(): numberReturns number
progress:Set(value)
Moves the bar to a value of 0..1.
progress:Set(value: number)| Parameter | Type |
|---|---|
value | number |
Returns nothing.
progress:SetColor(color)
Changes the colour of the filled part.
progress:SetColor(color: WaxColor)| Parameter | Type |
|---|---|
color | WaxColor |
Returns nothing.
WaxField
It can also do everything WaxControl can. You get one from container:Field. Below, field stands for one of these.
field:Set(value)
Replaces the value.
field:Set(value: any)| Parameter | Type |
|---|---|
value | any |
Returns nothing.
field:SetColor(color)
Changes the colour of the value.
field:SetColor(color: WaxColor)| Parameter | Type |
|---|---|
color | WaxColor |
Returns nothing.
WaxKeybind
It can also do everything WaxControl can. You get one from container:Keybind. Below, keybind stands for one of these.
| Signal | Handler receives | Description |
|---|---|---|
Changed | key: string | Fires with the engine's name of the key the user pressed. |
keybind:Get()
The key's engine name, or nil when none is set.
keybind:Get(): string?Returns string?
keybind:Set(key)
Sets the key without firing Changed.
keybind:Set(key: string?)| Parameter | Type |
|---|---|
key | string? |
Returns nothing.
WaxConsole
A log: coloured lines the user can select across (drag, Ctrl+A) and copy (Ctrl+C).
It can also do everything WaxControl can. You get one from container:Console. Below, console stands for one of these.
console:GetText()
Everything being shown, as one text (for ui.Copy).
console:GetText(): stringReturns string
console:SetLines(lines)
Shows these lines, or the last max of them.
console:SetLines(lines: WaxConsoleLine[])| Parameter | Type |
|---|---|
lines | WaxConsoleLine[] |
Returns nothing.
console:SetFollow(on)
Turns scrolling to the newest line on every SetLines on or off. It starts on.
console:SetFollow(on: boolean)| Parameter | Type |
|---|---|
on | boolean |
Returns nothing.
WaxGrid
A grid for any number of items: only the cells in view exist, and they are reused as it scrolls. It follows its scrolling while the menu is open, so it belongs in a window, not in an overlay.
It can also do everything WaxControl can. You get one from container:Grid. Below, grid stands for one of these.
grid:SetItems(items)
Shows another list, from the top.
grid:SetItems(items: any[])| Parameter | Type |
|---|---|
items | any[] |
Returns nothing.
grid:Refresh()
Shows every cell again, after the items themselves changed.
grid:Refresh()Returns nothing.
grid:Count()
How many items the grid has.
grid:Count(): integerReturns integer
WaxLabelOptions
Used by container:Label.
| Option | Type | Description |
|---|---|---|
dim | boolean | Uses the theme's secondary text colour. |
color | WaxColor | A colour in the linear form the engine uses. Make one with ui.Color. |
size | number | |
face | string | Typeface of the "ui" family: "Book", "Medium", "Bold" ... |
family | WaxFontFamily | "ui" (the game's own interface font) when omitted. |
WaxButtonOptions
Used by container:Button.
| Option | Type | Description |
|---|---|---|
primary | boolean | Draws the button in the accent colour. |
stretch | boolean | A button with a caption is as wide as its container. False keeps it as wide as its caption. An icon-only button is small unless this is true. |
icon | string | Icon name shown before the caption. The menu's Icons page lists the names. |
spin | boolean | The icon turns round once on every click, to show that something has started. |
WaxIconOptions
Used by container:Icon.
| Option | Type | Description |
|---|---|---|
size | number | Default 20. |
color | WaxColor | The theme's text colour when omitted. |
WaxSliderOptions
Used by container:Slider.
| Option | Type | Description |
|---|---|---|
min | number | Default 0. |
max | number | Default 1. |
value | number | The starting value. min when omitted. |
step | number | Values snap to this step, counted from min. |
format | string | string.format pattern for the read-out. "%.2f" when omitted, or "%d" with a step of 1 or more. |
stacked | boolean | True puts the caption above the track, false beside it. When omitted, the room available decides. |
live | boolean | False reports the value once, when the mouse lets go, for changes too heavy to make while dragging. True when omitted. |
WaxInputOptions
Used by container:Input.
| Option | Type | Description |
|---|---|---|
text | string | The starting text. |
hint | string | Greyed text shown while the box is empty. |
stacked | boolean | True puts the caption above the box, false beside it. When omitted, the room available decides. |
mono | boolean | A fixed-width font, for code. |
WaxSectionOptions
Used by container:Section.
| Option | Type | Description |
|---|---|---|
open | boolean | False starts the section collapsed. |
collapsible | boolean | False makes a plain titled group that is always open. |
WaxProgressOptions
Used by container:Progress.
| Option | Type | Description |
|---|---|---|
color | WaxColor | string | integer | The accent colour when omitted. "#RRGGBB" works too. |
WaxFieldOptions
Used by container:Field.
| Option | Type | Description |
|---|---|---|
mono | boolean | Shows the value in the small fixed-width font, for numbers that keep changing. |
WaxConsoleOptions
Used by container:Console.
| Option | Type | Description |
|---|---|---|
height | number | Default 220. On a page made with scroll = false it takes the space left when omitted. |
max | integer | The most lines shown. Default 150. |
WaxGridOptions
Used by container:Grid.
| Option | Type | Description |
|---|---|---|
make (required) | fun(cell: WaxContainer): any | Called once for each cell that is needed: add one control to cell and return whatever show needs. |
show (required) | fun(made: any, item: any, index: integer) | Called whenever a cell is to show another item. |
items | any[] | The list to show, of any length. |
cell | number | Least width of a cell. Default 38. As many columns as fit share the width. |
cell_height | number | Default: the same as cell. |
height | number | Default 300. On a page made with scroll = false the grid takes the space left when omitted. |
WaxFlowOptions
Used by container:Flow.
| Option | Type | Description |
|---|---|---|
cell | number | Makes it a grid: every control gets the same width, at least this, and each line is full. |
Named values
Short names for a fixed set of values. Where a function asks for one of these, pass one of the values listed.
WaxConsoleLine
One console line: the text, then an optional colour.
The same as { [1]: any, [2]: WaxColor? }.