Skip to content

CheckBox

A checkbox or radio button control with an optional label, description, and image. Supports a tri-state mode.

Create with AceGUI:Create("CheckBox"). It inherits the Common Widget API.

Widget type: CheckBox

Methods

SetValue

method#
lua
widget:SetValue(value?)

Sets the checked state and updates the check texture. In tri-state mode, a nil value shows a desaturated check to represent the "unknown/mixed" state; false hides the check; any truthy value shows the normal check.

Parameters

ParameterTypeDefaultDescription
value (optional)booleantrue (checked), false (unchecked), or nil (only meaningful in tri-state mode).

GetValue

method#
lua
widget:GetValue()

Returns the current checked state.

Returns

TypeDescription
booleanThe current checked state (true, false, or nil for the tri-state unknown value).

ToggleChecked

method#
lua
widget:ToggleChecked()

Cycles the value. In normal mode it flips between true/false. In tri-state mode it cycles in the order truenilfalsetrue.

SetTriState

method#
lua
widget:SetTriState(enabled)

Enables or disables tri-state behavior, then re-applies the current value so the display updates.

Parameters

ParameterTypeDefaultDescription
enabledbooleantrue to allow the third (nil) state.

SetType

method#
lua
widget:SetType(type?)

Switches the visual style between a checkbox and a radio button.

Parameters

ParameterTypeDefaultDescription
type (optional)string"radio" for radio-button textures (16px), or anything else / nil for the default checkbox textures (24px).

SetLabel

method#
lua
widget:SetLabel(label?)

Sets the text shown next to the box.

Parameters

ParameterTypeDefaultDescription
label (optional)stringThe label string.

SetDescription

method#
lua
widget:SetDescription(desc?)

Sets an optional supplementary description line beneath the label. Passing a value creates the description font string (if needed) and grows the widget height to fit it; passing nil/"" removes it and resets the height to 24.

Parameters

ParameterTypeDefaultDescription
desc (optional)stringThe description text, or nil/"" to remove it.

SetImage

method#
lua
widget:SetImage(path?, ...)

Sets an optional icon texture shown before the label and realigns the label accordingly.

Parameters

ParameterTypeDefaultDescription
path (optional)string | numberTexture path or file ID. nil clears the image.
...numberOptional tex-coords. Pass 4 values (for SetTexCoord(left, right, top, bottom)) or 8 values for the full corner form; otherwise the full texture (0, 1, 0, 1) is used.

SetDisabled

method#
lua
widget:SetDisabled(disabled)

Enables or disables the control. When disabled the label/description are greyed and the check is desaturated. When enabled, the check is desaturated only in tri-state mode with a nil value.

Parameters

ParameterTypeDefaultDescription
disabledbooleantrue to disable, false to enable.

OnWidthSet

method#
lua
widget:OnWidthSet(width)

Internal layout hook called when the width changes; re-wraps the description text and recomputes the height. Not normally called directly.

Parameters

ParameterTypeDefaultDescription
widthnumberThe new width.

Defaults

On acquire the control resets to: checkbox type (not radio), value false, tri-state off, width 200, no image, not disabled, and no description.

Callbacks

OnValueChanged

callback#
lua
OnValueChanged(checked?)

Fired when the user clicks the box (mouse up) and the value is toggled. A check-on/check-off sound is played first. Subscribe with widget:SetCallback.

Parameters

ParameterTypeDefaultDescription
checked (optional)booleanThe new value (true, false, or nil in tri-state).

OnEnter

callback#
lua
OnEnter()

Fired when the mouse enters the control. Subscribe with widget:SetCallback.

OnLeave

callback#
lua
OnLeave()

Fired when the mouse leaves the control. Subscribe with widget:SetCallback.

Example

lua
local cb = AceGUI:Create("CheckBox")
cb:SetLabel("Enable feature")
cb:SetDescription("Turns the feature on or off for this character.")
cb:SetValue(db.enabled)
cb:SetCallback("OnValueChanged", function(widget, event, checked)
    db.enabled = checked
end)

Ace3, a World of Warcraft addon framework.