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:GetPropagateKeyboardInput() - This function is not yet documented
- CheckButton:IsForbidden() - This function is not yet documented
- CheckButton:RegisterUnitEvent() - This function is not yet documented
- CheckButton:SetDontSavePosition() - This function is not yet documented
- CheckButton:SetEnabled() - This function is not yet documented
- CheckButton:SetPropagateKeyboardInput() - This function is not yet documented
- CheckButton:SetShown() - This function is not yet documented
- 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