Skip to content

Label

Displays text and optionally an icon, sizing its height dynamically to fit the content.

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

Widget type: Label

Methods

SetText

method#
lua
widget:SetText(text?)

Sets the label's text and re-lays out the text/image anchors.

Parameters

ParameterTypeDefaultDescription
text (optional)stringThe text to display. Passing nil clears it; zero-height labels are forced to 1px so they can serve as spacers.

SetColor

method#
lua
widget:SetColor(r?, g?, b?)

Sets the vertex color of the label text. If any component is missing, the color defaults to white (1, 1, 1).

Parameters

ParameterTypeDefaultDescription
r (optional)numberRed component in the range 01. Defaults to white (1, 1, 1) if any component is missing.
g (optional)numberGreen component in the range 01.
b (optional)numberBlue component in the range 01.

SetImage

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

Sets an optional image displayed alongside the text. When set, the image appears on the left if there is at least 200px of room for the text; otherwise it is centered on top. Passing a nil or invalid texture hides the image.

Parameters

ParameterTypeDefaultDescription
path (optional)string | numberTexture path or file ID, or nil to remove the image.
...numberOptional texture coordinates: either 4 (left, right, top, bottom) or 8 values. Any other count falls back to the full texture.

SetImageSize

method#
lua
widget:SetImageSize(width, height)

Sets the displayed size of the image and re-lays out the widget.

Parameters

ParameterTypeDefaultDescription
widthnumberImage width in pixels.
heightnumberImage height in pixels.

SetFont

method#
lua
widget:SetFont(font, height, flags)

Sets the label font using an internal, lazily-created font object.

Parameters

ParameterTypeDefaultDescription
fontstringFont file path.
heightnumberFont height in pixels.
flagsstringFont flags string (e.g. "OUTLINE").

SetFontObject

method#
lua
widget:SetFontObject(font?)

Sets the label's font from an existing font object. Defaults to GameFontHighlightSmall when nil.

Parameters

ParameterTypeDefaultDescription
font (optional)tableA font object, or nil for the default (GameFontHighlightSmall).

SetJustifyH

method#
lua
widget:SetJustifyH(justifyH)

Sets horizontal text justification.

Parameters

ParameterTypeDefaultDescription
justifyHstring"LEFT", "CENTER", or "RIGHT".

SetJustifyV

method#
lua
widget:SetJustifyV(justifyV)

Sets vertical text justification.

Parameters

ParameterTypeDefaultDescription
justifyVstring"TOP", "MIDDLE", or "BOTTOM".

OnWidthSet

method#
lua
widget:OnWidthSet(width)

Layout hook called by AceGUI when the width changes; re-anchors the text and image. Not normally called directly.

Parameters

ParameterTypeDefaultDescription
widthnumberThe new width.

Defaults

On acquire the label resets to: width 200, empty text, no image, image size 16×16, white color, default font object, horizontal justify LEFT, and vertical justify TOP. Height is always derived from the text and image.

Callbacks

This widget fires no widget-specific callbacks.

Example

lua
local label = AceGUI:Create("Label")
label:SetText("Status: ready")
label:SetColor(0, 1, 0)
label:SetImage("Interface\\Icons\\INV_Misc_QuestionMark")
label:SetImageSize(20, 20)

Ace3, a World of Warcraft addon framework.