CheckButtons are a specialized form of Button; they maintain an on/off state, which toggles automatically when they are clicked, and additional textures for when they are checked, or checked while disabled. A CheckButton's checked status can also be checked or set directly from Lua with :GetChecked() and :SetChecked(). CheckButtons do not need to look like check-boxes; the configurable checked textures allow you to create whatever appearance is suitable for a button that needs a persistent state.
While CheckButtons are particularly prevalent throughout the Interface Options UI, they are also found in places like the crafting UI (to restrict display of known recipes to those for which the materials are available). The most frequently used CheckButtons, however, are the action buttons on your action bars. They use the checked state to display a yellow border around spells or actions that are currently in progress, and include update code to adjust the checked state appropriately.
Although CheckButtons inherit the Button type's :SetText() and :GetText() methods, most CheckButtons templates are not set up to display their labels in this way. Instead, they include a FontString with the name $parentText, so that you set their text with _G[button:GetName().."Text"]:SetText(newLabel).
Some convenient CheckButton templates include UICheckButtonTemplate (the conventional general-purpose check button), InterfaceOptionsCheckButtonTemplate (for use with Interface Options panels) and ActionBarButtonTemplate.
Defined Methods
- enabled = CheckButton:GetChecked() - Returns whether the check button is checked
- texture = CheckButton:GetCheckedTexture() - Returns the texture used when the button is checked
- texture = CheckButton:GetDisabledCheckedTexture() - Returns the texture used when the button is disabled and checked
- CheckButton:SetChecked(enable) - Sets whether the check button is checked
- CheckButton:SetCheckedTexture(texture) or CheckButton:SetCheckedTexture("filename") - Sets the texture used when the button is checked
- CheckButton:SetDisabledCheckedTexture(texture) or CheckButton:SetDisabledCheckedTexture("filename") - Sets the texture used when the button is disabled and checked
Inherited Methods
- CheckButton:AllowAttributeChanges() - Temporarily allows insecure code to modify the frame's attributes during combat
- enabled = CheckButton:CanChangeAttribute() - Returns whether secure frame attributes can currently be changed
- canChange = CheckButton:CanChangeProtectedState() - Returns whether protected properties of the region can be changed by non-secure scripts
- CheckButton:ClearAllPoints() - Removes all anchor points from the region
- CheckButton:Click("button", down) - Performs a (virtual) mouse click on the button
- animationGroup = CheckButton:CreateAnimationGroup(["name" [, "inheritsFrom"]]) - Creates a new AnimationGroup as a child of the region
- fontstring = CheckButton:CreateFontString(["name" [, "layer" [, "inherits"]]]) - Creates a new [[docs/widgets/FontString|`FontString`]] as a child of the frame
- texture = CheckButton:CreateTexture(["name" [, "layer" [, "inherits"]]]) - Creates a new [[docs/widgets/Texture|`Texture`]] as a child of the frame
- region = CheckButton:CreateTitleRegion() - Creates a title region for dragging the frame
- CheckButton:Disable() - Disallows user interaction with the button
- CheckButton:DisableDrawLayer("layer") - Prevents display of all child objects of the frame on a specified graphics layer
- CheckButton:Enable() - Allows user interaction with the button
- CheckButton:EnableDrawLayer("layer") - Allows display of all child objects of the frame on a specified graphics layer
- CheckButton:EnableJoystick(enable) - Enables or disables joystick interactivity
- CheckButton:EnableKeyboard(enable) - Enables or disables keyboard interactivity for the frame
- CheckButton:EnableMouse(enable) - Enables or disables mouse interactivity for the frame
- CheckButton:EnableMouseWheel(enable) - Enables or disables mouse wheel interactivity for the frame
- alpha = CheckButton:GetAlpha() - Returns the opacity of the region relative to its parent
- ... = CheckButton:GetAnimationGroups() - Returns a list of animation groups belonging to the region
- value = CheckButton:GetAttribute("name") - Returns the value of a secure frame attribute
- backdrop = CheckButton:GetBackdrop() - Returns information about the frame's backdrop graphic
- red, green, blue, alpha = CheckButton:GetBackdropBorderColor() - Returns the shading color for the frame's border graphic
- red, green, blue, alpha = CheckButton:GetBackdropColor() - Returns the shading color for the frame's background graphic
- bottom = CheckButton:GetBottom() - Returns the distance from the bottom of the screen to the bottom of the region
- left, bottom, width, height = CheckButton:GetBoundsRect() - Returns the position and dimension of the smallest area enclosing the frame and its children
- state = CheckButton:GetButtonState() - Returns the button's current state
- x, y = CheckButton:GetCenter() - Returns the screen coordinates of the region's center
- ... = CheckButton:GetChildren() - Returns a list of child frames of the frame
- left, right, top, bottom = CheckButton:GetClampRectInsets() - Returns offsets from the frame's edges used when limiting user movement or resizing of the frame
- depth = CheckButton:GetDepth() - Returns the 3D depth of the frame (for stereoscopic 3D setups)
- font = CheckButton:GetDisabledFontObject() - Returns the font object used for the button's disabled state
- texture = CheckButton:GetDisabledTexture() - Returns the texture used when the button is disabled
- alpha = CheckButton:GetEffectiveAlpha() - Returns the overall opacity of the frame
- depth = CheckButton:GetEffectiveDepth() - Returns the overall 3D depth of the frame (for stereoscopic 3D configurations)
- scale = CheckButton:GetEffectiveScale() - Returns the overall scale factor of the frame
- fontstring = CheckButton:GetFontString() - Returns the `FontString` object used for the button's label text
- level = CheckButton:GetFrameLevel() - Sets the level at which the frame is layered relative to others in its strata
- strata = CheckButton:GetFrameStrata() - Returns the general layering strata of the frame
- height = CheckButton:GetHeight() - Returns the height of the region
- font = CheckButton:GetHighlightFontObject() - Returns the font object used when the button is highlighted
- texture = CheckButton:GetHighlightTexture() - Returns the texture used when the button is highlighted
- left, right, top, bottom = CheckButton:GetHitRectInsets() - Returns the insets from the frame's edges which determine its mouse-interactable area
- id = CheckButton:GetID() - Returns the frame's numeric identifier
- left = CheckButton:GetLeft() - Returns the distance from the left edge of the screen to the left edge of the region
- maxWidth, maxHeight = CheckButton:GetMaxResize() - Returns the maximum size of the frame for user resizing
- minWidth, minHeight = CheckButton:GetMinResize() - Returns the minimum size of the frame for user resizing
- isEnabled = CheckButton:GetMotionScriptsWhileDisabled() - Determines whether [[docs/scripts/OnEnter|OnEnter]]/[[docs/scripts/OnLeave|OnLeave]] scripts will fire while the button is disabled
- name = CheckButton:GetName() - Returns the widget object's name
- font = CheckButton:GetNormalFontObject() - Returns the font object used for the button's normal state
- texture = CheckButton:GetNormalTexture() - Returns the texture used for the button's normal state
- numChildren = CheckButton:GetNumChildren() - Returns the number of child frames belonging to the frame
- numPoints = CheckButton:GetNumPoints() - Returns the number of anchor points defined for the region
- numRegions = CheckButton:GetNumRegions() - Returns the number of non-Frame child regions belonging to the frame
- type = CheckButton:GetObjectType() - Returns the object's widget type
- parent = CheckButton:GetParent() - Returns the object's parent object
- point, relativeTo, relativePoint, xOffset, yOffset = CheckButton:GetPoint(index) - Returns information about one of the region's anchor points
- x, y = CheckButton:GetPushedTextOffset() - Returns the offset for moving the button's label text when pushed
- texture = CheckButton:GetPushedTexture() - Returns the texture used when the button is pushed
- left, bottom, width, height = CheckButton:GetRect() - Returns the position and dimensions of the region
- ... = CheckButton:GetRegions() - Returns a list of non-Frame child regions belonging to the frame
- right = CheckButton:GetRight() - Returns the distance from the left edge of the screen to the right edge of the region
- scale = CheckButton:GetScale() - Returns the frame's scale factor
- handler = CheckButton:GetScript("scriptType") - Returns the widget's handler function for a script
- width, height = CheckButton:GetSize() - Returns the width and height of the region
- text = CheckButton:GetText() - Returns the text of the button's label
- height = CheckButton:GetTextHeight() - Returns the height of the button's text label
- width = CheckButton:GetTextWidth() - Returns the width of the button's text label
- region = CheckButton:GetTitleRegion() - Returns the frame's TitleRegion object
- top = CheckButton:GetTop() - Returns the distance from the bottom of the screen to the top of the region
- width = CheckButton:GetWidth() - Returns the width of the region
- hasScript = CheckButton:HasScript("scriptType") - Returns whether the widget supports a script handler
- CheckButton:Hide() - Hides the region
- CheckButton:HookScript("scriptType", handler) - Securely hooks a script handler
- CheckButton:IgnoreDepth(enable) - Sets whether the frame's depth property is ignored (for stereoscopic 3D setups)
- enabled = CheckButton:IsClampedToScreen() - Returns whether the frame's boundaries are limited to those of the screen
- isDragging = CheckButton:IsDragging() - Returns whether the region is currently being dragged
- enabled = CheckButton:IsEnabled() - Returns whether user interaction with the button is allowed
- registered = CheckButton:IsEventRegistered("event") - Returns whether the frame is registered for a given [[docs/events|event]]
- enabled = CheckButton:IsIgnoringDepth() - Returns whether the frame's depth property is ignored (for stereoscopic 3D setups)
- enabled = CheckButton:IsJoystickEnabled() - Returns whether joystick interactivity is enabled for the frame
- enabled = CheckButton:IsKeyboardEnabled() - Returns whether keyboard interactivity is enabled for the frame
- enabled = CheckButton:IsMouseEnabled() - Returns whether mouse interactivity is enabled for the frame
- isOver = CheckButton:IsMouseOver() - Returns whether the mouse cursor is over the given region
- enabled = CheckButton:IsMouseWheelEnabled() - Returns whether mouse wheel interactivity is enabled for the frame
- movable = CheckButton:IsMovable() - Returns whether the frame can be moved by the user
- isType = CheckButton:IsObjectType("type") - Returns whether the object belongs to a given widget type
- isProtected, explicit = CheckButton:IsProtected() - Returns whether the region is protected
- enabled = CheckButton:IsResizable() - Returns whether the frame can be resized by the user
- shown = CheckButton:IsShown() - Returns whether the region is shown
- enabled = CheckButton:IsToplevel() - Returns whether the frame is automatically raised to the front when clicked
- enabled = CheckButton:IsUserPlaced() - Returns whether the frame is flagged for automatic saving and restoration of position and dimensions
- visible = CheckButton:IsVisible() - Returns whether the region is visible
- CheckButton:LockHighlight() - Locks the button in its highlight state
- CheckButton:Lower() - Reduces the frame's frame level below all other frames in its strata
- CheckButton:Raise() - Increases the frame's frame level above all other frames in its strata
- CheckButton:RegisterAllEvents() - Registers the frame for all events
- CheckButton:RegisterEvent("event") - Registers the frame for an [[docs/events|event]]
- CheckButton:RegisterForClicks(...) - Registers a button to receive mouse clicks
- CheckButton:RegisterForDrag(...) - Registers the frame for dragging
- CheckButton:SetAllPoints([region]) or CheckButton:SetAllPoints(["name"]) - Sets all anchor points of the region to match those of another region
- CheckButton:SetAlpha(alpha) - Sets the opacity of the region relative to its parent
- CheckButton:SetAttribute("name", value) - Sets a secure frame attribute
- CheckButton:SetBackdrop(backdrop) - Sets a backdrop graphic for the frame
- CheckButton:SetBackdropBorderColor(red, green, blue [, alpha]) - Sets a shading color for the frame's border graphic
- CheckButton:SetBackdropColor(red, green, blue [, alpha]) - Sets a shading color for the frame's background graphic
- CheckButton:SetButtonState("state", lock) - Sets the button's state
- CheckButton:SetClampRectInsets(left, right, top, bottom) - Sets offsets from the frame's edges used when limiting user movement or resizing of the frame
- CheckButton:SetClampedToScreen(enable) - Sets whether the frame's boundaries should be limited to those of the screen
- CheckButton:SetDepth(depth) - Sets the 3D depth of the frame (for stereoscopic 3D configurations)
- CheckButton:SetDisabledFontObject(font) - Sets the font object used for the button's disabled state
- CheckButton:SetDisabledTexture(texture) or CheckButton:SetDisabledTexture("filename") - Sets the texture used when the button is disabled
- CheckButton:SetFontString(fontstring) - Sets the `FontString` object used for the button's label text
- CheckButton:SetFormattedText("formatString", ...) - Sets the button's label text using format specifiers
- CheckButton:SetFrameLevel(level) - Sets the level at which the frame is layered relative to others in its strata
- CheckButton:SetFrameStrata("strata") - Sets the general layering strata of the frame
- CheckButton:SetHeight(height) - Sets the region's height
- CheckButton:SetHighlightFontObject(font) - Sets the font object used when the button is highlighted
- CheckButton:SetHighlightTexture(texture [, "mode"]) or CheckButton:SetHighlightTexture("filename" [, "mode"]) - Sets the texture used when the button is highlighted
- CheckButton:SetHitRectInsets(left, right, top, bottom) - Sets the insets from the frame's edges which determine its mouse-interactable area
- CheckButton:SetID(id) - Sets a numeric identifier for the frame
- CheckButton:SetMaxResize(maxWidth, maxHeight) - Sets the maximum size of the frame for user resizing
- CheckButton:SetMinResize(minWidth, minHeight) - Sets the minimum size of the frame for user resizing
- CheckButton:SetMotionScriptsWhileDisabled(enabled) - Sets whether the button should fire [[docs/scripts/OnEnter|OnEnter]]/[[docs/scripts/OnLeave|OnLeave]] events while disabled
- CheckButton:SetMovable(enable) - Sets whether the frame can be moved by the user
- CheckButton:SetNormalFontObject(font) - Sets the font object used for the button's normal state
- CheckButton:SetNormalTexture(texture) or CheckButton:SetNormalTexture("filename") - Sets the texture used for the button's normal state
- CheckButton:SetParent(frame) or CheckButton:SetParent("name") - Makes another frame the parent of this region
- CheckButton:SetPoint("point" [, relativeTo [, "relativePoint" [, xOffset [, yOffset]]]]) - Sets an anchor point for the region
- CheckButton:SetPushedTextOffset(x, y) - Sets the offset for moving the button's label text when pushed
- CheckButton:SetPushedTexture(texture) or CheckButton:SetPushedTexture("filename") - Sets the texture used when the button is pushed
- CheckButton:SetResizable(enable) - Sets whether the frame can be resized by the user
- CheckButton:SetScale(scale) - Sets the frame's scale factor
- CheckButton:SetScript("scriptType", handler) - Sets the widget's handler function for a script
- CheckButton:SetSize(width, height) - Sets the size of the region to the specified values
- CheckButton:SetText("text") - Sets the text displayed as the button's label
- CheckButton:SetToplevel(enable) - Sets whether the frame should automatically come to the front when clicked
- CheckButton:SetUserPlaced(enable) - Flags the frame for automatic saving and restoration of position and dimensions
- CheckButton:SetWidth(width) - Sets the region's width
- CheckButton:Show() - Shows the region
- CheckButton:StartMoving() - Begins repositioning the frame via mouse movement
- CheckButton:StartSizing() - Begins resizing the frame via mouse movement
- CheckButton:StopAnimating() - Stops any active animations involving the region or its children
- CheckButton:StopMovingOrSizing() - Ends movement or resizing of the frame initiated with [[docs/widgets/Frame/StartMoving|`:StartMoving()`]] or [[docs/widgets/Frame/StartSizing|`:StartSizing()`]]
- CheckButton:UnlockHighlight() - Unlocks the button's highlight state
- CheckButton:UnregisterAllEvents() - Unregisters the frame from any [[docs/events|events]] for which it is registered
- CheckButton:UnregisterEvent("event") - Unregisters the frame for an event
Script Handlers
- OnAttributeChanged(self, "name", value) - Run when a frame attribute is changed
- OnChar(self, "text") - Run for each text character typed in the frame
- OnClick(self, "button", down) - Run when the button is clicked
- OnDisable(self) - Run when the frame is disabled
- OnDoubleClick(self, "button") - Run when the button is double-clicked
- OnDragStart(self, "button") - Run when the mouse is dragged starting in the frame
- OnDragStop(self) - Run when the mouse button is released after a drag started in the frame
- OnEnable(self) - Run when the frame is enabled
- OnEnter(self, motion) - Run when the mouse cursor enters the frame's interactive area
- OnEvent(self, "event", ...) - Run whenever an [[docs/events|event]] fires for which the frame is registered
- OnHide(self) - Run when the frame's visbility changes to hidden
- OnKeyDown(self, "key") - Run when a keyboard key is pressed if the frame is keyboard enabled
- OnKeyUp(self, "key") - Run when a keyboard key is released if the frame is keyboard enabled
- OnLeave(self, motion) - Run when the mouse cursor leaves the frame's interactive area
- OnLoad(self) - Run when the frame is created
- OnMouseDown(self, "button") - Run when a mouse button is pressed while the cursor is over the frame
- OnMouseUp(self, "button") - Run when the mouse button is released following a mouse down action in the frame
- OnMouseWheel(self, delta) - Run when the frame receives a mouse wheel scrolling action
- OnReceiveDrag(self) - Run when the mouse button is released after dragging into the frame
- OnShow(self) - Run when the frame becomes visible
- OnSizeChanged(self, width, height) - Run when a frame's size changes
- OnUpdate(self, elapsed) - Run each time the screen is drawn by the game engine
- PostClick(self, "button", down) - Run immediately following the button's `OnClick` handler with the same arguments
- PreClick(self, "button", down) - Run immediately before the button's `OnClick` handler with the same arguments