WoW:USERAPI Frame SetManyAttributes: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→Example: Using it on a random frame) |
||
Line 22: | Line 22: | ||
frames[1]:SetManyAttributes("type1", "macro", "macrotext", "/equip Hydrocane") | frames[1]:SetManyAttributes("type1", "macro", "macrotext", "/equip Hydrocane") | ||
frames[2]:SetManyAttributes("type1", "spell", "spell", "Greater Heal") | frames[2]:SetManyAttributes("type1", "spell", "spell", "Greater Heal") | ||
Or to just use the function on a random frame: | |||
SetManyAttributes(someFrame, "type1", "macro", "macrotext", "/equip Hydrocane"); |
Revision as of 01:01, 26 May 2007
This page documents a <i>user-defined function</i> that you can copy and paste into your addon. Replace PREFIX with your addon or lib prefix to avoid conflicts between different versions of these functions.
Small function to be attached to secure frames to allow for setting many attributes in a single call.
local function SetManyAttributes(self, ...) for i=1,select("#", ...),2 do local att,val = select(i, ...) if not att then return end self:SetAttribute(att,val) end end
Example
local frames = {} for i=1,12 do frames[i] = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate") frames[i].SetManyAttributes = SetManyAttributes end frames[1]:SetManyAttributes("type1", "macro", "macrotext", "/equip Hydrocane") frames[2]:SetManyAttributes("type1", "spell", "spell", "Greater Heal")
Or to just use the function on a random frame:
SetManyAttributes(someFrame, "type1", "macro", "macrotext", "/equip Hydrocane");