Quantcast WoWInterface - View Single Post - HOWTO: Integrate your addon with Clique (under Cataclysm/4.x)
View Single Post
10-05-10, 04:52 PM   #1
Cladhaire's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 1,935
HOWTO: Integrate your addon with Clique (under Cataclysm/4.x)

Adding support for Clique - Non-Group-Headers

During the initialisation of your addon, do:

ClickCastFrames = ClickCastFrames or {}
Then for any button you create and want to register for click-casting:

ClickCastFrames[frameObject] = true
That's it!

Adding support for Clique - Group Headers

Unfortunately there was a rather drastic change to the group headers in 4.x that cause the registration process to be a bit convoluted. There are four requirements:
  1. Clique should be an optional dependency for your addon
  2. A frame reference on your group header to the Clique header.
  3. Some bootstrap code in your XML template for your unit frame
  4. Registration code in the initialConfigFunction

The first step is simple, simply include the following in your table of contents file, required to ensure the header exist before you try and use it.

## OptionalDeps: Clique
You will need to include some bootstrap code in an XML template for your unit frames. You can use the following code as an example:

<Button name="ClickCastUnitTemplate" virtual="true" inherits="SecureActionButtonTemplate,SecureHandlerEnterLeaveTemplate">
        <Attribute name="_onenter" type="string" value="local snippet = self:GetAttribute('clickcast_onenter'); if snippet then self:Run(snippet) end"/>
        <Attribute name="_onleave" type="string" value="local snippet = self:GetAttribute('clickcast_onleave'); if snippet then self:Run(snippet) end"/>
Next, after the group header frame has been created but before you've shown it, set a frame reference on it:

yourHeader:SetFrameRef("clickcast_header", ClickCastHeader)
Finally, in the initialConfigFunction snippet, run the following:

local header = self:GetParent():GetFrameRef("clickcast_header")
-- do not add this conditional in without testing, it will allow for incorrect
-- integration, so you should verify it works before adding this check.
if header then
  header:SetAttribute("clickcast_button", self)
If you have any suggestions for how to make this process easier, please let me know.
"There's only one thing that I know how to do well and I've often been told that you only can do what you know how to do well, and that's be you-- be what you're like-- be like yourself. And so I'm having a wonderful time, but I'd rather be whistling in the dark..."

Last edited by Cladhaire : 10-06-10 at 07:27 AM.
  Reply With Quote