12.07.2015 Views

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 29 ■ Widget <strong>Reference</strong> 1171are checked, or checked while disabled. A CheckButton’s checked status can also bechecked or set directly from Lua with :GetChecked() <strong>and</strong> :SetChecked(). Check-Buttons do not need to look like checkboxes; the configurable checked textures allowyou to create whatever appearance is suitable <strong>for</strong> 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 <strong>of</strong> known recipes tothose <strong>for</strong> which the materials are available). The most frequently used CheckButtons,however, are the action buttons on your action bars. They use the checked state todisplay a yellow border around spells or actions that are currently in progress, <strong>and</strong>include update code to adjust the checked state appropriately.Although CheckButtons inherit the Button type’s :SetText() <strong>and</strong> :GetText()methods, most CheckButtons templates are not set up to display their labels in thisway. Instead, they include a FontString with the name $parentText, sothatyousettheir text with _G[button:GetName()..“Text“]:SetText(newLabel).Some convenient CheckButton templates include UICheckButtonTemplate (the conventionalgeneral-purpose check button), InterfaceOptionsCheckButtonTemplate (<strong>for</strong>use with Interface Options panels) <strong>and</strong> ActionBarButtonTemplate.CheckButton has all the methods from Button, plus the following:GetCheckedReturns whether the check button is checked.enabled = CheckButton:GetChecked()Returns:enabled—1 if the button is checked; nil if the button is unchecked (1nil)GetCheckedTextureReturns the texture used when the button is checked.texture = CheckButton:GetCheckedTexture()Returns:texture—<strong>Reference</strong> to the Texture object used when the button is checked(texture)GetDisabledCheckedTextureReturns the texture used when the button is disabled <strong>and</strong> checked.texture = CheckButton:GetDisabledCheckedTexture()Returns:texture—<strong>Reference</strong> to the Texture object used when the button is disabled<strong>and</strong> checked (texture)SetCheckedSets whether the check button is checked.CheckButton:SetChecked(enable)Arguments:enable—True to check the button; false to uncheck (boolean)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!