Adding support for Clique - Non-Group-Headers
During the initialisation of your addon, do:
Code:
ClickCastFrames = ClickCastFrames or {}
Then for any button you create and want to register for click-casting:
Code:
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:
- Clique should be an optional dependency for your addon
- A frame reference on your group header to the Clique header.
- Some bootstrap code in your XML template for your unit frame
- 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.
Code:
## 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:
Code:
<Button name="ClickCastUnitTemplate" virtual="true" inherits="SecureActionButtonTemplate,SecureHandlerEnterLeaveTemplate">
<Attributes>
<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"/>
</Attributes>
</Button>
Next, after the group header frame has been created but before you've shown it, set a frame reference on it:
Code:
yourHeader:SetFrameRef("clickcast_header", ClickCastHeader)
Finally, in the initialConfigFunction snippet, run the following:
Code:
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)
header:RunAttribute("clickcast_register")
end
If you have any suggestions for how to make this process easier, please let me know.