View Single Post
01-09-12, 05:31 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
In addition to inheriting from ActionButtonTemplate (which will give you the hover/pushed textures) you also need to set the icon texture for the button.
Code:
local macroBtn = CreateFrame("Button", "Prospect", UIParent, "SecureActionButtonTemplate,ActionButtonTemplate")
(On a side note, using a generic name like "Prospect" for an object in the global namespace is generally considered bad form. You should give it a name that makes it immediately obvious what addon owns the button, such as "AngrysteelProspect".)

Get the correct texture file using the GetSpellInfo API:
Code:
local name, _, icon = GetSpellInfo(31252)
Then assign the texture file to the icon texture object created from the ActionButtonTemplate:
Code:
macroBtn.icon:SetTexture(icon)
You should probably also use the name returned from GetSpellInfo for the spell attribute, so your addon will work in all locales:
Code:
macroBtn:SetAttribute("spell", name)
Finally, semicolons are not necessary or useful in Lua. Unless you are really stuck on them from experience in some other programming language, you should just get rid of them, as they are generally considered ugly clutter in Lua.
  Reply With Quote