Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
No edit summary
Tag: WoW API docs
(19 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{wikify}}
+
{{widget}}
  +
<onlyinclude><includeonly><div style="font-size:smaller; float:right;">{{Edit|UIOBJECT CheckButton|Edit CheckButton}}</div></includeonly>[[UIOBJECT CheckButton|CheckButton]] (inherits from {{api|t=o|Button}}) comprises a {{api|t=w|CheckButton:SetChecked|tickable}} box beside a text label.</onlyinclude> Interacting with either the box or label toggles the button state between checked and not checked appearances.
   
== Making Checkboxes ==
+
== Construction ==
  +
=== Lua ===
  +
With "CheckButton" as the first argument in {{api|CreateFrame()}}
  +
<syntaxhighlight lang="lua">
  +
local cb = CreateFrame("CheckButton", "MyCheckButton", UIParent)
  +
</syntaxhighlight>
   
  +
=== XML ===
You can make a checkbox in WoW via the following commands:
 
  +
With a {{api|t=x|CheckButton}} element in an XML file.
myCheckButton = CreateFrame("CheckButton", "myCheckButton_GlobalName", parentFrame, "ChatConfigCheckButtonTemplate");
 
  +
<syntaxhighlight lang="xml">
  +
<CheckButton name="MyCheckButton" parent="UIParent">
  +
<!-- insert anchors, scripts, children and other components here in XML -->
  +
</CheckButton>
  +
</syntaxhighlight>
   
  +
== Methods ==
  +
=== CheckButton ===
  +
<onlyinclude>{{#switch:{{{t|widgetmethod}}}|w|wm|widgetmethod=
  +
: {{api|t=w|CheckButton:GetChecked}}() - Get the status of the checkbox.
  +
: {{api|t=w|CheckButton:GetCheckedTexture}}() - Get the texture used for a checked box
  +
: {{api|t=w|CheckButton:GetDisabledCheckedTexture}}() - Get the texture used for a disabled checked box
  +
: {{api|t=w|CheckButton:SetChecked}}(boolean) - Set the status of the checkbox.
  +
: {{api|t=w|CheckButton:SetCheckedTexture}}(texture) - Set the texture to use for a checked box.
  +
: {{api|t=w|CheckButton:SetDisabledCheckedTexture}}(texture) - Set the texture to use for a disabled but checked box.
  +
}}</onlyinclude>
   
  +
=== Button ===
  +
{{:UIOBJECT Button|t=w}}
   
  +
=== Frame ===
This is where you locate the checkbox relative to its parent frame. Coordinates are (0,0) is the top-left corner of the parent, so a negative y-coordinate means down and positive x-coord means right.
 
  +
{{:UIOBJECT Frame|t=w}}
myCheckButton:SetPoint("TOPLEFT", 200, -65);
 
   
  +
=== Region ===
  +
{{:UIOBJECT Region|t=w}}
   
  +
=== UIObject ===
  +
{{:UIOBJECT UIObject|t=w}}
   
  +
=== ScriptObject ===
You can reference the name of your Check Box either by writing it explicitly, or by making a function call. Writing it explicitly "looks prettier", but might be confusing to anyone looking at your code, as the name for it seems made-up. Note arg2 in the creation call. It is the same as what is below, but we have appended it with "Text". This is necessary, I don't know why they didn't just set it up so you can do myCheckButton:Text, but we must work with what we're given.
 
  +
{{:UIOBJECT ScriptObject|t=w}}
myCheckButton_GlobalNameText:SetText("CheckBox Name");
 
Here is the code to do the exact same thing, but it's not explicitly written. This is (arguably) less confusing.
 
getglobal(myCheckButton:GetName() .. 'Text'):SetText("CheckBox Name");
 
   
  +
== Handlers ==
  +
CheckButton does not introduce any new handlers, but inherits from Button. Notably, its {{api|t=w|CheckButton:GetChecked()|GetChecked}} method reflects the new state during Button's OnClick handler.
   
  +
=== Button ===
  +
{{:UIOBJECT Button|t=wh}}
   
  +
=== Frame ===
When mousing over your checkbox, you can have a tooltip appear, which is useful to describe the actions resulting from clicking the checkbox, without putting it all in the name.
 
  +
{{:UIOBJECT Frame|t=wh}}
myCheckButton.tooltip = "This is where you place MouseOver Text.";
 
   
  +
=== ScriptObject ===
  +
{{:UIOBJECT ScriptObject|t=wh}}
   
   
  +
== Examples ==
Set up what happens when you click the checkbox. You can add other scripts similarly to how I have this one, you just need to change the "OnClick" to whatever else. http://www.wowwiki.com/Category:Widget_event_handlers Note that you can't pass arguments to the "OnClick" script's function, but you can do other things as in a normal function
 
  +
The following example provides a basic CheckButton inheriting a common template to configure its default appearance.
myCheckButton:SetScript("OnClick",
 
  +
<syntaxhighlight lang="lua">
function()
 
 
local myCheckButton = CreateFrame("CheckButton", nil, UIParent, "ChatConfigCheckButtonTemplate")
--do stuff
 
 
myCheckButton:SetPoint("TOPLEFT", 200, -65)
end);
 
 
myCheckButton:SetText("CheckBox Name")
 
myCheckButton.tooltip = "This is where you place MouseOver Text."
 
myCheckButton:HookScript("OnClick", function()
 
--do stuff
  +
end)
  +
</syntaxhighlight>
   
  +
The following example creates a "checkbox-[http://en.wikipedia.org/wiki/Factory_(software_concept) factory] function" to automate several steps (but could be substituted using a [[FramePoolMixin]]):
  +
<syntaxhighlight lang="lua">
  +
local numCheckButtons = 0;
  +
function createCheckButton(parent, xOff, yOff, displayname)
  +
numCheckButtons = numCheckButtons + 1;
 
local checkButton = CreateFrame("CheckButton", "my_addon_checkbutton_" .. numCheckButtons, parent, "ChatConfigCheckButtonTemplate");
 
checkButton:SetPoint("TOPLEFT", xOff or 0, yOff or 0);
  +
checkButton:SetText(displayname or "");
  +
return checkbutton;
  +
end
   
  +
myCheckButton = my_addon.createCheckButton(UIParent, 400, -600, "A Checkbox");
  +
myCheckButton.tooltip = "If this is checked, nothing will happen, because this is a demo checkbox.";
 
myCheckButton:HookScript("OnClick", function()
 
-- do stuff
 
end);
  +
</syntaxhighlight>
   
== Example entirely in Lua ==
+
== Patch changes ==
  +
* {{Patch 1.11.0|note=Added functions to retrieve the textures in use on the tick box<ref name="1.11.0">{{ref web|author={{Blizz}}[[Slouken]]|date=2006-04-27|title=Re:Upcoming 1.11 Changes - Concise List|url=http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=343889&p=#post368568|archiveurl=http://blue.cardplace.com/cache/wow-interface-customization/343889.htm}}</ref>}}
myCheckButton = CreateFrame("CheckButton", "myCheckButton_GlobalName", parentFrame, "ChatConfigCheckButtonTemplate");
 
  +
myCheckButton:SetPoint("TOPLEFT", 200, -65);
 
  +
== External links ==
myCheckButton_GlobalNameText:SetText("CheckBox Name");
 
  +
<!-- Please read https://wow.gamepedia.com/Wowpedia:External_links_policy before adding new links. -->
myCheckButton.tooltip = "This is where you place MouseOver Text.";
 
  +
{{Elinks-api|wowprog=}}
myCheckButton:SetScript("OnClick",
 
  +
function()
 
  +
== References ==
--do stuff
 
  +
{{Reflist}}
end);
 

Revision as of 23:19, 29 May 2021

CheckButton (inherits from Button) comprises a tickable box beside a text label. Interacting with either the box or label toggles the button state between checked and not checked appearances.

Construction

Lua

With "CheckButton" as the first argument in CreateFrame()

local cb = CreateFrame("CheckButton", "MyCheckButton", UIParent)

XML

With a <CheckButton> element in an XML file.

<CheckButton name="MyCheckButton" parent="UIParent">
	<!-- insert anchors, scripts, children and other components here in XML -->
</CheckButton>

Methods

CheckButton

CheckButton:GetChecked() - Get the status of the checkbox.
CheckButton:GetCheckedTexture() - Get the texture used for a checked box
CheckButton:GetDisabledCheckedTexture() - Get the texture used for a disabled checked box
CheckButton:SetChecked(boolean) - Set the status of the checkbox.
CheckButton:SetCheckedTexture(texture) - Set the texture to use for a checked box.
CheckButton:SetDisabledCheckedTexture(texture) - Set the texture to use for a disabled but checked box.

Button

Button:ClearDisabledTexture()
Button:ClearHighlightTexture()
Button:ClearNormalTexture()
Button:ClearPushedTexture()
Button:Click([button, isDown]) - Performs a virtual mouse click on the button.
Button:Disable()
Button:Enable()
Button:GetButtonState() : buttonState
Button:GetDisabledFontObject() : font
Button:GetDisabledTexture() : texture
Button:GetFontString() : fontString
Button:GetHighlightFontObject() : font
Button:GetHighlightTexture() : texture - Returns the highlight texture for the button.
Button:GetMotionScriptsWhileDisabled() : motionScriptsWhileDisabled
Button:GetNormalFontObject() : font - Returns the font object for the button's normal state.
Button:GetNormalTexture() : texture
Button:GetPushedTextOffset() : offsetX, offsetY
Button:GetPushedTexture() : texture
Button:GetText() : text - Returns the text on the button.
Button:GetTextHeight() : height
Button:GetTextWidth() : width
Button:IsEnabled() : isEnabled - Returns true if the button is enabled.
Button:LockHighlight()
Button:RegisterForClicks([button1, ...]) - Registers the button widget to receive mouse clicks.
Button:RegisterForMouse(unpackedPrimitiveType, ...)
Button:SetButtonState(buttonState [, lock])
Button:SetDisabledAtlas(atlas)
Button:SetDisabledFontObject(font)
Button:SetDisabledTexture(asset)
Button:SetEnabled([enabled])
Button:SetFontString(fontString)
Button:SetFormattedText(text)
Button:SetHighlightAtlas(atlas [, blendMode])
Button:SetHighlightFontObject(font)
Button:SetHighlightLocked(locked)
Button:SetHighlightTexture(asset [, blendMode])
Button:SetMotionScriptsWhileDisabled(motionScriptsWhileDisabled)
Button:SetNormalAtlas(atlas)
Button:SetNormalFontObject(font) - Sets the font object used for the button's normal state.
Button:SetNormalTexture(asset) - Sets the normal texture for a button.
Button:SetPushedAtlas(atlas)
Button:SetPushedTextOffset(offsetX, offsetY)
Button:SetPushedTexture(asset)
Button:SetText([text]) - Sets the text of the button.
Button:UnlockHighlight()
OnClick(self, self, button, down) - Invoked when clicking a button.
OnDoubleClick(self, self, button) - Invoked when double-clicking a button.
PostClick(self, button, down) - Invoked immediately after `OnClick`.
PreClick(self, button, down) - Invoked immediately before `OnClick`.

Frame

Frame:AbortDrag()
Frame:CanChangeAttribute() : canChangeAttributes
Frame:CreateFontString([name, drawLayer, templateName]) : line - Creates a fontstring.
Frame:CreateLine([name, drawLayer, templateName, subLevel]) : line - Draws a line.
Frame:CreateMaskTexture([name, drawLayer, templateName, subLevel]) : maskTexture - Creates a mask texture.
Frame:CreateTexture([name, drawLayer, templateName, subLevel]) : texture - Creates a texture.
Frame:DesaturateHierarchy(desaturation [, excludeRoot])
Frame:DisableDrawLayer(layer) - Prevents display of the frame on the specified draw layer.
Frame:DoesClipChildren() : clipsChildren
Frame:EnableDrawLayer(layer) - Allows display of the frame on the specified draw layer.
Frame:EnableGamePadButton([enable]) - Allows the receipt of gamepad button inputs for this frame.
Frame:EnableGamePadStick([enable]) - Allows the receipt of gamepad stick inputs for this frame.
Frame:EnableKeyboard([enable]) - Allows this frame to receive keyboard input.
Frame:ExecuteAttribute(attributeName, unpackedPrimitiveType, ...) : success, unpackedPrimitiveType, ...
Frame:GetAlpha() : alpha -> Region:GetAlpha
Frame:GetAttribute(attributeName) : value - Returns the value of a secure frame attribute.
Frame:GetBoundsRect() : left, bottom, width, height
Frame:GetChildren() : child1, ... - Returns a list of child frames belonging to the frame.
Frame:GetClampRectInsets() : left, right, top, bottom - Returns the frame's clamp rectangle offsets.
Frame:GetDontSavePosition() : dontSave
Frame:GetEffectiveAlpha() : effectiveAlpha - Returns the effective alpha after propagating from the parent region.
Frame:GetEffectiveScale() : effectiveScale - Returns the effective scale after propagating from the parent region.
Frame:GetEffectivelyFlattensRenderLayers() : flatten - Returns true if render layer flattening has been implicitly enabled.
Frame:GetFlattensRenderLayers() : flatten - Returns true if render layer flattening has been enabled.
Frame:GetFrameLevel() : frameLevel - Returns the frame level of the frame.
Frame:GetFrameStrata() : strata - Returns the layering strata of the frame.
Frame:GetHitRectInsets() : left, right, top, bottom - Returns the insets of the frame's hit rectangle.
Frame:GetHyperlinksEnabled() : enabled - Returns true if mouse interaction with hyperlinks on the frame is enabled.
Frame:GetID() : id - Returns the frame's numeric identifier.
Frame:GetNumChildren() : numChildren - Returns the number of child frames belonging to the frame.
Frame:GetNumRegions() : numRegions - Returns the number of non-Frame child regions belonging to the frame.
Frame:GetPropagateKeyboardInput() : propagate - Returns whether the frame propagates keyboard events.
Frame:GetRegions() : region1, ... - Returns a list of non-Frame child regions belonging to the frame.
Frame:GetResizeBounds() : minWidth, minHeight, maxWidth, maxHeight - Returns the minimum and maximum size of the frame for user resizing.
Frame:GetScale() : frameScale -> Region:GetScale
Frame:HasFixedFrameLevel() : isFixed
Frame:HasFixedFrameStrata() : isFixed
Frame:Hide() -> ScriptRegion:Hide
Frame:InterceptStartDrag(delegate)
Frame:IsClampedToScreen() : clampedToScreen - Returns whether a frame is prevented from being moved off-screen.
Frame:IsEventRegistered(eventName) : isRegistered, unit1, ... - Returns whether a frame is registered to an event.
Frame:IsGamePadButtonEnabled() : enabled - Checks if this frame is configured to receive gamepad button inputs.
Frame:IsGamePadStickEnabled() : enabled - Checks if this frame is configured to receive gamepad stick inputs.
Frame:IsIgnoringParentAlpha() : ignore -> Region:IsIgnoringParentAlpha
Frame:IsIgnoringParentScale() : ignore -> Region:IsIgnoringParentScale
Frame:IsKeyboardEnabled() : enabled - Returns true if keyboard interactivity is enabled for the frame.
Frame:IsMovable() : isMovable - Returns true if the frame is movable.
Frame:IsObjectLoaded() : isLoaded -> Region:IsObjectLoaded
Frame:IsResizable() : resizable - Returns true if the frame can be resized by the user.
Frame:IsShown() : isShown -> ScriptRegion:IsShown
Frame:IsToplevel() : isTopLevel - Returns whether this frame should raise its frame level on mouse interaction.
Frame:IsUserPlaced() : isUserPlaced - Returns whether the frame has been moved by the user.
Frame:IsVisible() : isVisible -> ScriptRegion:IsVisible
Frame:Lower() - Reduces the frame's frame level below all other frames in its strata.
Frame:Raise() - Increases the frame's frame level above all other frames in its strata.
Frame:RegisterAllEvents() - Flags the frame to receive all events.
Frame:RegisterEvent(eventName) : registered - Registers the frame to an event.
Frame:RegisterForDrag([button1, ...]) - Registers the frame for dragging with a mouse button.
Frame:RegisterUnitEvent(eventName [, unit1, ...]) : registered - Registers the frame for a specific event, triggering only for the specified units.
Frame:RotateTextures(radians [, x, y])
Frame:SetAlpha(alpha) -> Region:SetAlpha
Frame:SetAttribute(attributeName, value) - Sets an attribute on the frame.
Frame:SetAttributeNoHandler(attributeName, value) - Sets an attribute on the frame without triggering the OnAttributeChanged script handler.
Frame:SetClampRectInsets(left, right, top, bottom) - Controls how much of the frame may be moved off-screen.
Frame:SetClampedToScreen(clampedToScreen) - Prevents the frame from moving off-screen.
Frame:SetClipsChildren(clipsChildren)
Frame:SetDontSavePosition(dontSave)
Frame:SetDrawLayerEnabled(layer [, isEnabled])
Frame:SetFixedFrameLevel(isFixed)
Frame:SetFixedFrameStrata(isFixed)
Frame:SetFlattensRenderLayers(flatten) - Controls whether all subregions are composited into a single render layer.
Frame:SetFrameLevel(frameLevel) - Sets the level at which the frame is layered relative to others in its strata.
Frame:SetFrameStrata(strata) - Sets the layering strata of the frame.
Frame:SetHitRectInsets(left, right, top, bottom) #secureframe - Returns the insets of the frame's hit rectangle.
Frame:SetHyperlinksEnabled([enabled]) - Allows mouse interaction with hyperlinks on the frame.
Frame:SetID(id) - Returns the frame's numeric identifier.
Frame:SetIgnoreParentAlpha(ignore) -> Region:SetIgnoreParentAlpha
Frame:SetIgnoreParentScale(ignore) -> Region:SetIgnoreParentScale
Frame:SetIsFrameBuffer(isFrameBuffer) - Controls whether or not a frame is rendered to its own framebuffer prior to being composited atop the UI.
Frame:SetMovable(movable) - Sets whether the frame can be moved.
Frame:SetPropagateKeyboardInput(propagate) #nocombat - Sets whether keyboard input is consumed by this frame or propagates to further frames.
Frame:SetResizable(resizable) - Sets whether the frame can be resized by the user.
Frame:SetResizeBounds(minWidth, minHeight [, maxWidth, maxHeight]) - Sets the minimum and maximum size of the frame for user resizing.
Frame:SetScale(scale) -> Region:SetScale
Frame:SetShown([shown]) -> ScriptRegion:SetShown
Frame:SetToplevel(topLevel) #secureframe - Controls whether or not a frame should raise its frame level on mouse interaction.
Frame:SetUserPlaced(userPlaced) - Sets whether a frame has been moved by the user and will be saved in the layout cache.
Frame:Show() -> ScriptRegion:Show
Frame:StartMoving([alwaysStartFromMouse]) - Begins repositioning the frame via mouse movement.
Frame:StartSizing([resizePoint, alwaysStartFromMouse]) - Begins resizing the frame via mouse movement.
Frame:StopMovingOrSizing() - Stops moving or resizing the frame.
Frame:UnregisterAllEvents() - Unregisters all events from the frame.
Frame:UnregisterEvent(eventName) : registered - Unregisters an event from the frame.
OnAttributeChanged(self, key, value) - Invoked when a secure frame attribute is changed.
OnChar(self, text) - Invoked for each text character typed in the frame.
OnDisable(self) - Invoked when the frame is disabled.
OnDragStart(self, button) - Invoked when the mouse is dragged starting in the frame
OnDragStop(self) - Invoked when the mouse button is released after a drag started in the frame,
OnEnable(self) - Invoked when the frame is enabled.
OnEvent(self, event, ...) - Invoked whenever an event fires for which the frame is registered.
OnGamePadButtonDown(self, button) - Invoked when a gamepad button is pressed.
OnGamePadButtonUp(self, button) - Invoked when a gamepad button is released.
OnGamePadStick(self, stick, x, y, len) - Invoked when a gamepad stick is moved.
OnHyperlinkClick(self, link, text, button, region, left, bottom, width, height) - Invoked when the mouse clicks a hyperlink on the FontInstance object.
OnHyperlinkEnter(self, link, text, region, left, bottom, width, height) - Invoked when the mouse moves over a hyperlink on the FontInstance object.
OnHyperlinkLeave(self) - Invoked when the mouse moves away from a hyperlink on the FontInstance object.
OnKeyDown(self, key) - Invoked when a keyboard key is pressed if the frame is keyboard enabled.
OnKeyUp(self, key) - Invoked when a keyboard key is released if the frame is keyboard enabled.
OnReceiveDrag(self) - Invoked when the mouse button is released after dragging into the frame.
OnSizeChanged(self, width, height) - Invoked when a frame's size changes.

Region

Region:GetAlpha() : alpha - Returns the region's opacity.
Region:GetDrawLayer() : layer, sublayer - Returns the layer in which the region is drawn.
Region:GetEffectiveScale() : effectiveScale - Returns the scale of the region after propagating from its parents.
Region:GetScale() : scale - Returns the scale of the region.
Region:GetVertexColor() : colorR, colorG, colorB, colorA - Returns the vertex color shading of the region.
Region:IsIgnoringParentAlpha() : isIgnoring - Returns true if the region is ignoring parent alpha.
Region:IsIgnoringParentScale() : isIgnoring - Returns true if the region is ignoring parent scale.
Region:IsObjectLoaded() : isLoaded - Returns true if the region is fully loaded.
Region:SetAlpha(alpha) - Sets the opacity of the region.
Region:SetDrawLayer(layer [, sublevel]) - Sets the layer in which the region is drawn.
Region:SetIgnoreParentAlpha(ignore) - Sets whether the region should ignore its parent's alpha.
Region:SetIgnoreParentScale(ignore) - Sets whether the region should ignore its parent's scale.
Region:SetScale(scale) - Sets the size scaling of the region.
Region:SetVertexColor(colorR, colorG, colorB [, a]) - Sets the vertex shading color of the region.

UIObject

UIObject is an abstract widget type that all user interface elements derive from.

UIObject:GetName() - Returns the widget object's name.
UIObject:GetObjectType() - Returns the object's widget type.
UIObject:IsObjectType(type) - Returns whether the object belongs to a given widget type.

ScriptObject

ScriptObject is an abstract widget type that provides support for widget scripts.

ScriptObject:GetScript(scriptType [, bindingType]) - Returns the widget's script handler.
ScriptObject:SetScript(scriptType, handler) - Sets the widget's script handler.
ScriptObject:HookScript(scriptType, handler [, bindingType]) - Securely hooks a script handler.
ScriptObject:HasScript(scriptType) - Returns whether the widget supports a script type.

Handlers

CheckButton does not introduce any new handlers, but inherits from Button. Notably, its GetChecked() method reflects the new state during Button's OnClick handler.

Button

Button:ClearDisabledTexture()
Button:ClearHighlightTexture()
Button:ClearNormalTexture()
Button:ClearPushedTexture()
Button:Click([button, isDown]) - Performs a virtual mouse click on the button.
Button:Disable()
Button:Enable()
Button:GetButtonState() : buttonState
Button:GetDisabledFontObject() : font
Button:GetDisabledTexture() : texture
Button:GetFontString() : fontString
Button:GetHighlightFontObject() : font
Button:GetHighlightTexture() : texture - Returns the highlight texture for the button.
Button:GetMotionScriptsWhileDisabled() : motionScriptsWhileDisabled
Button:GetNormalFontObject() : font - Returns the font object for the button's normal state.
Button:GetNormalTexture() : texture
Button:GetPushedTextOffset() : offsetX, offsetY
Button:GetPushedTexture() : texture
Button:GetText() : text - Returns the text on the button.
Button:GetTextHeight() : height
Button:GetTextWidth() : width
Button:IsEnabled() : isEnabled - Returns true if the button is enabled.
Button:LockHighlight()
Button:RegisterForClicks([button1, ...]) - Registers the button widget to receive mouse clicks.
Button:RegisterForMouse(unpackedPrimitiveType, ...)
Button:SetButtonState(buttonState [, lock])
Button:SetDisabledAtlas(atlas)
Button:SetDisabledFontObject(font)
Button:SetDisabledTexture(asset)
Button:SetEnabled([enabled])
Button:SetFontString(fontString)
Button:SetFormattedText(text)
Button:SetHighlightAtlas(atlas [, blendMode])
Button:SetHighlightFontObject(font)
Button:SetHighlightLocked(locked)
Button:SetHighlightTexture(asset [, blendMode])
Button:SetMotionScriptsWhileDisabled(motionScriptsWhileDisabled)
Button:SetNormalAtlas(atlas)
Button:SetNormalFontObject(font) - Sets the font object used for the button's normal state.
Button:SetNormalTexture(asset) - Sets the normal texture for a button.
Button:SetPushedAtlas(atlas)
Button:SetPushedTextOffset(offsetX, offsetY)
Button:SetPushedTexture(asset)
Button:SetText([text]) - Sets the text of the button.
Button:UnlockHighlight()
OnClick(self, self, button, down) - Invoked when clicking a button.
OnDoubleClick(self, self, button) - Invoked when double-clicking a button.
PostClick(self, button, down) - Invoked immediately after `OnClick`.
PreClick(self, button, down) - Invoked immediately before `OnClick`.

Frame

Frame:AbortDrag()
Frame:CanChangeAttribute() : canChangeAttributes
Frame:CreateFontString([name, drawLayer, templateName]) : line - Creates a fontstring.
Frame:CreateLine([name, drawLayer, templateName, subLevel]) : line - Draws a line.
Frame:CreateMaskTexture([name, drawLayer, templateName, subLevel]) : maskTexture - Creates a mask texture.
Frame:CreateTexture([name, drawLayer, templateName, subLevel]) : texture - Creates a texture.
Frame:DesaturateHierarchy(desaturation [, excludeRoot])
Frame:DisableDrawLayer(layer) - Prevents display of the frame on the specified draw layer.
Frame:DoesClipChildren() : clipsChildren
Frame:EnableDrawLayer(layer) - Allows display of the frame on the specified draw layer.
Frame:EnableGamePadButton([enable]) - Allows the receipt of gamepad button inputs for this frame.
Frame:EnableGamePadStick([enable]) - Allows the receipt of gamepad stick inputs for this frame.
Frame:EnableKeyboard([enable]) - Allows this frame to receive keyboard input.
Frame:ExecuteAttribute(attributeName, unpackedPrimitiveType, ...) : success, unpackedPrimitiveType, ...
Frame:GetAlpha() : alpha -> Region:GetAlpha
Frame:GetAttribute(attributeName) : value - Returns the value of a secure frame attribute.
Frame:GetBoundsRect() : left, bottom, width, height
Frame:GetChildren() : child1, ... - Returns a list of child frames belonging to the frame.
Frame:GetClampRectInsets() : left, right, top, bottom - Returns the frame's clamp rectangle offsets.
Frame:GetDontSavePosition() : dontSave
Frame:GetEffectiveAlpha() : effectiveAlpha - Returns the effective alpha after propagating from the parent region.
Frame:GetEffectiveScale() : effectiveScale - Returns the effective scale after propagating from the parent region.
Frame:GetEffectivelyFlattensRenderLayers() : flatten - Returns true if render layer flattening has been implicitly enabled.
Frame:GetFlattensRenderLayers() : flatten - Returns true if render layer flattening has been enabled.
Frame:GetFrameLevel() : frameLevel - Returns the frame level of the frame.
Frame:GetFrameStrata() : strata - Returns the layering strata of the frame.
Frame:GetHitRectInsets() : left, right, top, bottom - Returns the insets of the frame's hit rectangle.
Frame:GetHyperlinksEnabled() : enabled - Returns true if mouse interaction with hyperlinks on the frame is enabled.
Frame:GetID() : id - Returns the frame's numeric identifier.
Frame:GetNumChildren() : numChildren - Returns the number of child frames belonging to the frame.
Frame:GetNumRegions() : numRegions - Returns the number of non-Frame child regions belonging to the frame.
Frame:GetPropagateKeyboardInput() : propagate - Returns whether the frame propagates keyboard events.
Frame:GetRegions() : region1, ... - Returns a list of non-Frame child regions belonging to the frame.
Frame:GetResizeBounds() : minWidth, minHeight, maxWidth, maxHeight - Returns the minimum and maximum size of the frame for user resizing.
Frame:GetScale() : frameScale -> Region:GetScale
Frame:HasFixedFrameLevel() : isFixed
Frame:HasFixedFrameStrata() : isFixed
Frame:Hide() -> ScriptRegion:Hide
Frame:InterceptStartDrag(delegate)
Frame:IsClampedToScreen() : clampedToScreen - Returns whether a frame is prevented from being moved off-screen.
Frame:IsEventRegistered(eventName) : isRegistered, unit1, ... - Returns whether a frame is registered to an event.
Frame:IsGamePadButtonEnabled() : enabled - Checks if this frame is configured to receive gamepad button inputs.
Frame:IsGamePadStickEnabled() : enabled - Checks if this frame is configured to receive gamepad stick inputs.
Frame:IsIgnoringParentAlpha() : ignore -> Region:IsIgnoringParentAlpha
Frame:IsIgnoringParentScale() : ignore -> Region:IsIgnoringParentScale
Frame:IsKeyboardEnabled() : enabled - Returns true if keyboard interactivity is enabled for the frame.
Frame:IsMovable() : isMovable - Returns true if the frame is movable.
Frame:IsObjectLoaded() : isLoaded -> Region:IsObjectLoaded
Frame:IsResizable() : resizable - Returns true if the frame can be resized by the user.
Frame:IsShown() : isShown -> ScriptRegion:IsShown
Frame:IsToplevel() : isTopLevel - Returns whether this frame should raise its frame level on mouse interaction.
Frame:IsUserPlaced() : isUserPlaced - Returns whether the frame has been moved by the user.
Frame:IsVisible() : isVisible -> ScriptRegion:IsVisible
Frame:Lower() - Reduces the frame's frame level below all other frames in its strata.
Frame:Raise() - Increases the frame's frame level above all other frames in its strata.
Frame:RegisterAllEvents() - Flags the frame to receive all events.
Frame:RegisterEvent(eventName) : registered - Registers the frame to an event.
Frame:RegisterForDrag([button1, ...]) - Registers the frame for dragging with a mouse button.
Frame:RegisterUnitEvent(eventName [, unit1, ...]) : registered - Registers the frame for a specific event, triggering only for the specified units.
Frame:RotateTextures(radians [, x, y])
Frame:SetAlpha(alpha) -> Region:SetAlpha
Frame:SetAttribute(attributeName, value) - Sets an attribute on the frame.
Frame:SetAttributeNoHandler(attributeName, value) - Sets an attribute on the frame without triggering the OnAttributeChanged script handler.
Frame:SetClampRectInsets(left, right, top, bottom) - Controls how much of the frame may be moved off-screen.
Frame:SetClampedToScreen(clampedToScreen) - Prevents the frame from moving off-screen.
Frame:SetClipsChildren(clipsChildren)
Frame:SetDontSavePosition(dontSave)
Frame:SetDrawLayerEnabled(layer [, isEnabled])
Frame:SetFixedFrameLevel(isFixed)
Frame:SetFixedFrameStrata(isFixed)
Frame:SetFlattensRenderLayers(flatten) - Controls whether all subregions are composited into a single render layer.
Frame:SetFrameLevel(frameLevel) - Sets the level at which the frame is layered relative to others in its strata.
Frame:SetFrameStrata(strata) - Sets the layering strata of the frame.
Frame:SetHitRectInsets(left, right, top, bottom) #secureframe - Returns the insets of the frame's hit rectangle.
Frame:SetHyperlinksEnabled([enabled]) - Allows mouse interaction with hyperlinks on the frame.
Frame:SetID(id) - Returns the frame's numeric identifier.
Frame:SetIgnoreParentAlpha(ignore) -> Region:SetIgnoreParentAlpha
Frame:SetIgnoreParentScale(ignore) -> Region:SetIgnoreParentScale
Frame:SetIsFrameBuffer(isFrameBuffer) - Controls whether or not a frame is rendered to its own framebuffer prior to being composited atop the UI.
Frame:SetMovable(movable) - Sets whether the frame can be moved.
Frame:SetPropagateKeyboardInput(propagate) #nocombat - Sets whether keyboard input is consumed by this frame or propagates to further frames.
Frame:SetResizable(resizable) - Sets whether the frame can be resized by the user.
Frame:SetResizeBounds(minWidth, minHeight [, maxWidth, maxHeight]) - Sets the minimum and maximum size of the frame for user resizing.
Frame:SetScale(scale) -> Region:SetScale
Frame:SetShown([shown]) -> ScriptRegion:SetShown
Frame:SetToplevel(topLevel) #secureframe - Controls whether or not a frame should raise its frame level on mouse interaction.
Frame:SetUserPlaced(userPlaced) - Sets whether a frame has been moved by the user and will be saved in the layout cache.
Frame:Show() -> ScriptRegion:Show
Frame:StartMoving([alwaysStartFromMouse]) - Begins repositioning the frame via mouse movement.
Frame:StartSizing([resizePoint, alwaysStartFromMouse]) - Begins resizing the frame via mouse movement.
Frame:StopMovingOrSizing() - Stops moving or resizing the frame.
Frame:UnregisterAllEvents() - Unregisters all events from the frame.
Frame:UnregisterEvent(eventName) : registered - Unregisters an event from the frame.
OnAttributeChanged(self, key, value) - Invoked when a secure frame attribute is changed.
OnChar(self, text) - Invoked for each text character typed in the frame.
OnDisable(self) - Invoked when the frame is disabled.
OnDragStart(self, button) - Invoked when the mouse is dragged starting in the frame
OnDragStop(self) - Invoked when the mouse button is released after a drag started in the frame,
OnEnable(self) - Invoked when the frame is enabled.
OnEvent(self, event, ...) - Invoked whenever an event fires for which the frame is registered.
OnGamePadButtonDown(self, button) - Invoked when a gamepad button is pressed.
OnGamePadButtonUp(self, button) - Invoked when a gamepad button is released.
OnGamePadStick(self, stick, x, y, len) - Invoked when a gamepad stick is moved.
OnHyperlinkClick(self, link, text, button, region, left, bottom, width, height) - Invoked when the mouse clicks a hyperlink on the FontInstance object.
OnHyperlinkEnter(self, link, text, region, left, bottom, width, height) - Invoked when the mouse moves over a hyperlink on the FontInstance object.
OnHyperlinkLeave(self) - Invoked when the mouse moves away from a hyperlink on the FontInstance object.
OnKeyDown(self, key) - Invoked when a keyboard key is pressed if the frame is keyboard enabled.
OnKeyUp(self, key) - Invoked when a keyboard key is released if the frame is keyboard enabled.
OnReceiveDrag(self) - Invoked when the mouse button is released after dragging into the frame.
OnSizeChanged(self, width, height) - Invoked when a frame's size changes.

ScriptObject

ScriptObject is an abstract widget type that provides support for widget scripts.

OnLoad(self) - Run when the frame is created.
OnUpdate(self, elapsed) - Run each time the screen is drawn by the game engine.


Examples

The following example provides a basic CheckButton inheriting a common template to configure its default appearance.

local myCheckButton = CreateFrame("CheckButton", nil, UIParent, "ChatConfigCheckButtonTemplate")
myCheckButton:SetPoint("TOPLEFT", 200, -65)
myCheckButton:SetText("CheckBox Name")
myCheckButton.tooltip = "This is where you place MouseOver Text."
myCheckButton:HookScript("OnClick", function()
	--do stuff
end)

The following example creates a "checkbox-factory function" to automate several steps (but could be substituted using a FramePoolMixin):

local numCheckButtons = 0;
function createCheckButton(parent, xOff, yOff, displayname)
	numCheckButtons =  numCheckButtons + 1;
	local checkButton = CreateFrame("CheckButton", "my_addon_checkbutton_" ..  numCheckButtons, parent, "ChatConfigCheckButtonTemplate");
	checkButton:SetPoint("TOPLEFT", xOff or 0, yOff or 0);
	checkButton:SetText(displayname or "");
	return checkbutton;
end

myCheckButton = my_addon.createCheckButton(UIParent, 400, -600, "A Checkbox");
myCheckButton.tooltip = "If this is checked, nothing will happen, because this is a demo checkbox.";
myCheckButton:HookScript("OnClick", function()
	-- do stuff
end);

Patch changes

  • WoW Icon update Patch 1.11.0 (2006-06-19): Added functions to retrieve the textures in use on the tick box[1]

External links

References