Wax

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
ParameterType
contentany
options (optional)WaxLabelOptions

Returns WaxLabel

container:Heading(content)

Adds a bold title line.

container:Heading(content: any): WaxHeading
ParameterType
contentany

Returns WaxHeading

container:Separator()

Adds a thin dividing line.

container:Separator(): WaxControl

Returns 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
ParameterType
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
ParameterType
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
ParameterType
namestring
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
ParameterType
captionstring
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
ParameterType
captionstring
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
ParameterType
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
ParameterTypeDescription
captionstring
choicesT[]
selected (optional)TThe 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
ParameterType
titlestring
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
ParameterType
contentstring
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(): WaxRow

Returns 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
ParameterTypeDescription
captionstring
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
ParameterType
optionsWaxGridOptions

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
ParameterType
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
ParameterType
captionstring
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
ParameterType
namestring
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
ParameterType
captionstring
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
ParameterType
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.

SignalHandler receivesDescription
Changeddepends on the controlFires 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)
ParameterType
shownboolean

Returns nothing.

control:SetEnabled(enabled)

Greys the control out and stops it reacting, or makes it usable again.

control:SetEnabled(enabled: boolean)
ParameterType
enabledboolean

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)
ParameterType
valueany

Returns nothing.

label:SetColor(color)

Changes the text colour.

label:SetColor(color: WaxColor)
ParameterType
colorWaxColor

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)
ParameterType
valueany

Returns nothing.

WaxButton

It can also do everything WaxControl can. You get one from container:Button. Below, button stands for one of these.

SignalHandler receivesDescription
ActivatednothingFires on each click, after on_click.
ChangednothingThe same signal as Activated.

button:SetIcon(name)

Shows another icon on a button that was made with one.

button:SetIcon(name: string)
ParameterType
namestring

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)
ParameterType
namestring

Returns nothing.

WaxToggle

It can also do everything WaxControl can. You get one from container:Toggle. Below, toggle stands for one of these.

SignalHandler receivesDescription
Changedon: booleanFires when the user flips the switch.

toggle:Get()

True while the switch is on.

toggle:Get(): boolean

Returns boolean

toggle:Set(on, instant?)

Turns the switch on or off without firing Changed.

toggle:Set(on: boolean, instant?: boolean)
ParameterTypeDescription
onboolean
instant (optional)booleanTrue 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)
ParameterType
textstring

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.

SignalHandler receivesDescription
Changedcolor: stringFires with "#rrggbb" on every change, also while the mouse is held.
Releasedcolor: stringFires once when the user lets go, or commits a typed colour. Use it for saving.

colorControl:Get()

The colour as "#rrggbb".

colorControl:Get(): string

Returns string

colorControl:Set(color)

Sets the colour without firing Changed.

colorControl:Set(color: string)
ParameterTypeDescription
colorstring"#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)
ParameterType
contentany

Returns nothing.

title:SetDescription(description)

Changes the line under the title (only if the title was made with one).

title:SetDescription(description: any)
ParameterType
descriptionany

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.

SignalHandler receivesDescription
Changedvalue: numberFires with each new value while the user drags (once, on letting go, with live = false), and when a number is typed.
Releasedvalue: numberFires once when the user lets go, for changes too heavy to apply during the drag.

slider:Get()

The current value.

slider:Get(): number

Returns number

slider:Set(value)

Moves the slider (snapped and kept within its range) without firing Changed.

slider:Set(value: number)
ParameterType
valuenumber

Returns nothing.

WaxInput

It can also do everything WaxControl can. You get one from container:Input. Below, input stands for one of these.

SignalHandler receivesDescription
Changedtext: stringFires when the text is committed (Enter, or the box losing focus).
Enteredtext: stringFires only when Enter is pressed, even when the text is the same as last time (for a command line).
Typedtext: stringFires on every change to the text while typing.

input:Get()

The text in the box.

input:Get(): string

Returns 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(): boolean

Returns 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)
ParameterTypeDescription
textstringEmpty to show nothing.

Returns nothing.

input:Set(text)

Replaces the text without firing Changed.

input:Set(text: any)
ParameterType
textany

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.

SignalHandler receivesDescription
Changedchoice: anyFires when the user picks a choice.

The selected choice.

dropdown:Get(): any

Returns any

Selects a choice without firing Changed.

dropdown:Set(choice: any)
ParameterType
choiceany

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.

PropertyTypeDescription
controlWaxControlThe card itself, for Destroy, SetVisible and SetEnabled.

section:SetOpen(open)

Expands or collapses the section.

section:SetOpen(open: boolean)
ParameterType
openboolean

Returns nothing.

section:IsOpen()

True while the section is expanded.

section:IsOpen(): boolean

Returns 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.

PropertyTypeDescription
controlWaxControlThe 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(): number

Returns number

progress:Set(value)

Moves the bar to a value of 0..1.

progress:Set(value: number)
ParameterType
valuenumber

Returns nothing.

progress:SetColor(color)

Changes the colour of the filled part.

progress:SetColor(color: WaxColor)
ParameterType
colorWaxColor

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)
ParameterType
valueany

Returns nothing.

field:SetColor(color)

Changes the colour of the value.

field:SetColor(color: WaxColor)
ParameterType
colorWaxColor

Returns nothing.

WaxKeybind

It can also do everything WaxControl can. You get one from container:Keybind. Below, keybind stands for one of these.

SignalHandler receivesDescription
Changedkey: stringFires 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?)
ParameterType
keystring?

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(): string

Returns string

console:SetLines(lines)

Shows these lines, or the last max of them.

console:SetLines(lines: WaxConsoleLine[])
ParameterType
linesWaxConsoleLine[]

Returns nothing.

console:SetFollow(on)

Turns scrolling to the newest line on every SetLines on or off. It starts on.

console:SetFollow(on: boolean)
ParameterType
onboolean

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[])
ParameterType
itemsany[]

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(): integer

Returns integer

WaxLabelOptions

Used by container:Label.

OptionTypeDescription
dimbooleanUses the theme's secondary text colour.
colorWaxColorA colour in the linear form the engine uses. Make one with ui.Color.
sizenumber
facestringTypeface of the "ui" family: "Book", "Medium", "Bold" ...
familyWaxFontFamily"ui" (the game's own interface font) when omitted.

WaxButtonOptions

Used by container:Button.

OptionTypeDescription
primarybooleanDraws the button in the accent colour.
stretchbooleanA 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.
iconstringIcon name shown before the caption. The menu's Icons page lists the names.
spinbooleanThe icon turns round once on every click, to show that something has started.

WaxIconOptions

Used by container:Icon.

OptionTypeDescription
sizenumberDefault 20.
colorWaxColorThe theme's text colour when omitted.

WaxSliderOptions

Used by container:Slider.

OptionTypeDescription
minnumberDefault 0.
maxnumberDefault 1.
valuenumberThe starting value. min when omitted.
stepnumberValues snap to this step, counted from min.
formatstringstring.format pattern for the read-out. "%.2f" when omitted, or "%d" with a step of 1 or more.
stackedbooleanTrue puts the caption above the track, false beside it. When omitted, the room available decides.
livebooleanFalse 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.

OptionTypeDescription
textstringThe starting text.
hintstringGreyed text shown while the box is empty.
stackedbooleanTrue puts the caption above the box, false beside it. When omitted, the room available decides.
monobooleanA fixed-width font, for code.

WaxSectionOptions

Used by container:Section.

OptionTypeDescription
openbooleanFalse starts the section collapsed.
collapsiblebooleanFalse makes a plain titled group that is always open.

WaxProgressOptions

Used by container:Progress.

OptionTypeDescription
colorWaxColor | string | integerThe accent colour when omitted. "#RRGGBB" works too.

WaxFieldOptions

Used by container:Field.

OptionTypeDescription
monobooleanShows the value in the small fixed-width font, for numbers that keep changing.

WaxConsoleOptions

Used by container:Console.

OptionTypeDescription
heightnumberDefault 220. On a page made with scroll = false it takes the space left when omitted.
maxintegerThe most lines shown. Default 150.

WaxGridOptions

Used by container:Grid.

OptionTypeDescription
make (required)fun(cell: WaxContainer): anyCalled 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.
itemsany[]The list to show, of any length.
cellnumberLeast width of a cell. Default 38. As many columns as fit share the width.
cell_heightnumberDefault: the same as cell.
heightnumberDefault 300. On a page made with scroll = false the grid takes the space left when omitted.

WaxFlowOptions

Used by container:Flow.

OptionTypeDescription
cellnumberMakes 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? }.

On this page

WaxContainercontainer:Label(content, options?)container:Heading(content)container:Separator()container:Spacer(height?)container:Button(caption?, on_click?, options?)container:Icon(name, options?)container:Toggle(caption, initial?, on_change?)container:Slider(caption, options?, on_change?)container:Input(caption?, options?, on_commit?)container:Dropdown(caption, choices, selected?, on_change?)container:Section(title, options?)container:Title(content, description?)container:Row()container:Color(caption, color?, on_change?)container:Grid(options)container:Flow(options?)container:Progress(caption, value?, options?)container:Field(name, value?, options?)container:Keybind(caption, key?, on_change?)container:Console(options?)WaxControlcontrol:Destroy()control:SetVisible(shown)control:SetEnabled(enabled)WaxLabellabel:Set(value)label:SetColor(color)WaxHeadingheading:Set(value)WaxButtonbutton:SetIcon(name)button:Spin()WaxIconicon:Set(name)WaxToggletoggle:Get()toggle:Set(on, instant?)toggle:SetCaption(text)WaxColorControlcolorControl:Get()colorControl:Set(color)WaxTitletitle:Set(content)title:SetDescription(description)WaxSliderslider:Get()slider:Set(value)WaxInputinput:Get()input:Focus()input:HasFocus()input:SetGhost(text)input:Set(text)WaxDropdowndropdown:Get()dropdown:Set(choice)WaxSectionsection:SetOpen(open)section:IsOpen()WaxRowWaxProgressprogress:Get()progress:Set(value)progress:SetColor(color)WaxFieldfield:Set(value)field:SetColor(color)WaxKeybindkeybind:Get()keybind:Set(key)WaxConsoleconsole:GetText()console:SetLines(lines)console:SetFollow(on)WaxGridgrid:SetItems(items)grid:Refresh()grid:Count()WaxLabelOptionsWaxButtonOptionsWaxIconOptionsWaxSliderOptionsWaxInputOptionsWaxSectionOptionsWaxProgressOptionsWaxFieldOptionsWaxConsoleOptionsWaxGridOptionsWaxFlowOptionsNamed valuesWaxConsoleLine