CheckButton
Jump to navigation
Jump to search
Instantiation | CreateFrame("CheckButton")
|
CheckButton comprises a tickable box beside a text label. Interacting with anything within the HitRectInsets toggles the button state between checked and not checked appearances.
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
|
|
Collapse |
---|
|
Script Types
|
Example
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.Text: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 function createCheckButton(parent, xOff, yOff, displayname)
local checkButton = CreateFrame("CheckButton", nil, parent, "ChatConfigCheckButtonTemplate");
checkButton:SetPoint("TOPLEFT", xOff or 0, yOff or 0);
checkButton.Text:SetText(displayname or "");
return checkButton;
end
local myCheckButton = 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
- Patch 1.11.0 (2006-06-19): Added functions to retrieve the textures in use on the tick box[1]
References
- ^ Slouken 2006-04-27. Re:Upcoming 1.11 Changes - Concise List. Archived from the original