Skip to content

Icon ​

A clickable icon button that displays a texture with an optional caption beneath it.

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

Widget type: Icon

Methods ​

SetLabel ​

method#
lua
widget:SetLabel(text?)

Sets the caption shown below the icon. Passing a non-empty string shows the label and sizes the widget to the image height plus 25px; passing nil or an empty string hides the label and sizes to the image height plus 10px.

Parameters

ParameterTypeDefaultDescription
text (optional)stringThe caption to display, or nil/"" to hide it.

SetImage ​

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

Sets the icon texture. If texture coordinates are supplied as the trailing arguments, they are applied; otherwise the full texture (0, 1, 0, 1) is used.

Parameters

ParameterTypeDefaultDescription
path (optional)string numberTexture path or file ID. nil clears 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 icon texture and adjusts the widget height accordingly (image height plus 25px when a label is shown, plus 10px otherwise).

Parameters

ParameterTypeDefaultDescription
widthnumberTexture width in pixels.
heightnumberTexture height in pixels.

SetDisabled ​

method#
lua
widget:SetDisabled(disabled)

Enables or disables the icon. When disabled, the button stops responding and the label and image are greyed out.

Parameters

ParameterTypeDefaultDescription
disabledbooleantrue to disable, false to enable.

Defaults ​

On acquire the icon resets to: width 110, height 110, no label, no image, image size 64×64, and not disabled.

Deprecated

SetText is a deprecated alias for SetLabel and prints a warning. Use SetLabel instead.

Callbacks ​

OnClick ​

callback#
lua
OnClick(button)

Fired when the icon is clicked; AceGUI clears focus afterward. Subscribe with widget:SetCallback.

Parameters

ParameterTypeDefaultDescription
buttonstringThe mouse button that was pressed (e.g. "LeftButton").

OnEnter ​

callback#
lua
OnEnter()

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

OnLeave ​

callback#
lua
OnLeave()

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

Example ​

lua
local icon = AceGUI:Create("Icon")
icon:SetImage("Interface\\Icons\\INV_Misc_QuestionMark")
icon:SetImageSize(48, 48)
icon:SetLabel("Help")
icon:SetCallback("OnClick", function(widget, event, button)
    print("Clicked with", button)
end)

Ace3, a World of Warcraft addon framework.