#0 - Nov. 30, 2006, 5:43 p.m.
I. On buttons
For most of the examples I use a combination of SecureActionButtonTemplate and ActionBarButtonTemplate. This gains us all the functionality of default Blizzard action buttons for very nearly free. The basic format is:
local btn = CreateFrame("CheckButton", "testbutton", UIParent, "ActionBarButtonTemplate")
-- required for the buttons to work correctly
btn:SetScript("OnAttributeChanged", ActionButton_Update)
-- if the user has Slouken's ShiftClickFix installed - apply it
if ShiftFixClick_ActionButton then ShiftFixClick_ActionButton(btn) end
btn:SetAttribute("type", "action")
btn:SetAttribute("action", 1)
Note that we set the "OnAttributeChanged" handler for the button to "ActionButton_Update". By doing this, when the action ID of the button changes due to a state change, the button will update to reflect that change. The next 2 lines specify that we want the button to behave as an action button with an ID of 1 (the same as the first button on the first bar of your default action bar).
(1 of 5)
EDIT - note that you no longer have to descend from SecureActionButton to use ActionBarButtons - Slouken unified them.
EDIT - note the the ShiftClickFix line - if the user has installed Slouken's ShiftClickFix mod, then this will apply that fix. No longer necessary after TBC release.