I know how to set attributes but I can't figure out how to put the icon and cooldown on the button, actually I'm really only interested in the cooldown (frame?). I'm probably asking the wrong question here.
What I want is a copy of my action bar that's not actually a real action bar, but only displays the icon (or texture) and the cooldown animation.
You don't need secure frames for that. If it's strictly for visual interaction, you can just do this:
-- inside for loop (or whatever you use to populate the frames).
local f = CreateFrame("Button", "frame_name"..uid, parentFrame, "ActionButtonTemplate") -- uid = unique index number
_G["frame_name"..uid.."Icon"]:SetTexture(texture) -- texture = the spell's icon
f.spell = "spell name"
f:SetScript("OnUpdate", function(self, ...)
Edit: There may be a more efficient way, the above was dry coded.
local function UpdateCooldowns()
for i = 1, numSpells do
Another question, I tried to make a range check on the buttons but my event driven function failed since there are no events that fire as you move in/out of range of something.
Looking through blizzards code I noticed it runs an OnUpdate script with range check included. So is that what I have to do? Create my own OnUpdate to check range?
And if so, let's say I do 1 check every second and each check goes through 20 spells, will that create a lot of cpu processing?
If you check the FrameXML file, you can see how Blizzard does it for their actionbars. Just do a find for "ActionButton_UpdateCooldown", which is the function that calls the cooldown update. They did register it to ACTIONBAR_UPDATE_COOLDOWN like you did, but it is also called in ActionButton_Update, which itself is called on ACTIONBAR_SLOT_CHANGED and PLAYER_ENTERING_WORLD.