Reply
 
Thread Tools Display Modes
Old 10-05-10, 04:52 PM   #1
Cladhaire
Salad!
 
Cladhaire's Avatar
Premium Member
WoWInterface Super Mod
Featured
Join Date: Jul 2005
Posts: 1,933
HOWTO: Integrate your addon with Clique (under Cataclysm/4.x)

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:
  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.

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.
__________________
"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.
Cladhaire is offline   Reply With Quote
Old 10-06-10, 08:37 PM   #2
Shefki
An Aku'mai Servant
 
Shefki's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 31
You'll need to wrap the SetFrameRef like so:

Code:
if ClickCastHeader then
  yourHeader:SetFrameRef("clickcast_header", ClickCastHeader)
end
SetFrameRef throws an error if you pass it nil.
Shefki is offline   Reply With Quote
Old 10-07-10, 03:05 AM   #3
Cladhaire
Salad!
 
Cladhaire's Avatar
Premium Member
WoWInterface Super Mod
Featured
Join Date: Jul 2005
Posts: 1,933
That has the problem that is silently breaks, so that's why I did not suggest it.
__________________
"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..."
Cladhaire is offline   Reply With Quote
Old 10-07-10, 08:29 PM   #4
Shefki
An Aku'mai Servant
 
Shefki's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 31
You also should mention that you need to do:
SecureHandler_OnLoad(yourHeader)

otherwise SetFrameRef isn't available on the frame.

Alternatively you can just run:
SecureHandlerSetFrameRef(yourHeader,"clickcast_header", ClickCastHeader)
Shefki is offline   Reply With Quote
Old 10-08-10, 12:53 AM   #5
Cladhaire
Salad!
 
Cladhaire's Avatar
Premium Member
WoWInterface Super Mod
Featured
Join Date: Jul 2005
Posts: 1,933
Correct, or you can inherit from the header base template.
__________________
"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..."
Cladhaire is offline   Reply With Quote
Old 10-09-10, 11:10 AM   #6
Shefki
An Aku'mai Servant
 
Shefki's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 31
You can't inherit it because the group headers already have an OnLoad.
Shefki is offline   Reply With Quote
Old 10-14-10, 06:03 PM   #7
Bobtehbuildr
A Murloc Raider
Join Date: Apr 2009
Posts: 5
OK, I got it mostly working. Here's what I have done.

My Party Frame had to inherit from both SecurePartyHeaderTemplate and SecureHandlerBaseTemplate.

Now I could do the Frame:SetFrameRef("clickcast_header", ClickCastHeader)";

I updated the initialConfigFunction as an attribute and used the following snippet for the value.

[[
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
]];

My template for my unit button also needed to inherit from both SecureUnitButtonTemplate and SecureHandlerEnterLeaveTemplate.

I added the following attributes to the template also.

<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>

The only problems I have left are as follows.

How do I get the new buttons that are created into the ClickCastFrames table? The buttons are generated dynamically by SecurePartyHeaderTemplate and I don't get "notified" until the initialConfigFunction snippet is processed. I'm going to try to add it to the snippet but I'm not sure if that will work.

Also I can't seem to get the menu to work on my buttons. The menu works on the stock UI frames.
Bobtehbuildr is offline   Reply With Quote
Old 10-15-10, 02:02 AM   #8
Cladhaire
Salad!
 
Cladhaire's Avatar
Premium Member
WoWInterface Super Mod
Featured
Join Date: Jul 2005
Posts: 1,933
Originally Posted by Bobtehbuildr View Post
OK, I got it mostly working. Here's what I have done.

My Party Frame had to inherit from both SecurePartyHeaderTemplate and SecureHandlerBaseTemplate.
This is actually the only tricky bit. You can't do this, because they both have OnLoad scripts, and only one of them will run. Inherit from SecurePartyHeaderTemplate, and then run the following code after you've created the header:

SecureHandler_OnLoad(yourHeader)

That adds the methods that we get from SecureHandlerBaseTempate without conflicting!

Now I could do the Frame:SetFrameRef("clickcast_header", ClickCastHeader)";

I updated the initialConfigFunction as an attribute and used the following snippet for the value.

[[
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
]];

My template for my unit button also needed to inherit from both SecureUnitButtonTemplate and SecureHandlerEnterLeaveTemplate.

I added the following attributes to the template also.

<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>

The only problems I have left are as follows.

How do I get the new buttons that are created into the ClickCastFrames table? The buttons are generated dynamically by SecurePartyHeaderTemplate and I don't get "notified" until the initialConfigFunction snippet is processed. I'm going to try to add it to the snippet but I'm not sure if that will work.
You can't, but you don't need to. You setting clickcast_button and then calling clickcast_register is the group header equivalent of ClickcastFrames[frame] = true.

Also I can't seem to get the menu to work on my buttons. The menu works on the stock UI frames.
Clique uses the WoW standard, where the menu function goes in the frame.menu slot and you use the "menu" attribute. If you use that, it should work.
__________________
"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..."
Cladhaire is offline   Reply With Quote
Old 10-15-10, 05:21 AM   #9
Bobtehbuildr
A Murloc Raider
Join Date: Apr 2009
Posts: 5
Is there a better way to do party frames? Without WoWs Secure Party Template?

I used to do my own layout but I had issues where I couldn't rearrange the buttons if I was in combat. Any ideas?

If I'm doing it the "wrong" way I don't mind changing it.
Bobtehbuildr is offline   Reply With Quote
Old 10-15-10, 09:39 AM   #10
Cladhaire
Salad!
 
Cladhaire's Avatar
Premium Member
WoWInterface Super Mod
Featured
Join Date: Jul 2005
Posts: 1,933
I'm not really sure I understand your question. If you want party frames, you can create them ahead of time without using the group headers. If you want frames created during combat without having to create all of them ahead of time, you can use the headers. That's what they are there for.
__________________
"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..."
Cladhaire is offline   Reply With Quote
Old 10-15-10, 05:20 PM   #11
Bobtehbuildr
A Murloc Raider
Join Date: Apr 2009
Posts: 5
Originally Posted by Cladhaire View Post
I'm not really sure I understand your question. If you want party frames, you can create them ahead of time without using the group headers. If you want frames created during combat without having to create all of them ahead of time, you can use the headers. That's what they are there for.
First off thank you for your time and your addon. I know how much time an addon can take. Your mod is going to take a lot of load off me. I also really like the interface.

Back to the question at hand. I know I can create the frames before combat but what happens when a UI is reloaded while in combat? I will not be able to create the frames right?

Maybe I need to learn a little more about secure frames. Is there a time during load that you can create secure frames and move them around without tainting the system?

Thanks again for your time.
Bobtehbuildr is offline   Reply With Quote
Old 10-16-10, 03:01 AM   #12
Cladhaire
Salad!
 
Cladhaire's Avatar
Premium Member
WoWInterface Super Mod
Featured
Join Date: Jul 2005
Posts: 1,933
Originally Posted by Bobtehbuildr View Post
First off thank you for your time and your addon. I know how much time an addon can take. Your mod is going to take a lot of load off me. I also really like the interface.

Back to the question at hand. I know I can create the frames before combat but what happens when a UI is reloaded while in combat? I will not be able to create the frames right?

Maybe I need to learn a little more about secure frames. Is there a time during load that you can create secure frames and move them around without tainting the system?

Thanks again for your time.
If the user interface is loaded while you are in combat, you are able to create frames and set attributes until just after the PLAYER_REGEN_DISABLED event, where InCombatLockdown() returns true and you can no longer to do this.
__________________
"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..."
Cladhaire is offline   Reply With Quote
Old 10-17-10, 01:20 PM   #13
Bobtehbuildr
A Murloc Raider
Join Date: Apr 2009
Posts: 5
Originally Posted by Cladhaire View Post
If the user interface is loaded while you are in combat, you are able to create frames and set attributes until just after the PLAYER_REGEN_DISABLED event, where InCombatLockdown() returns true and you can no longer to do this.
Thanks so much. I never new this! My addon has been updated and I now support Clique. ROXORS!
Bobtehbuildr is offline   Reply With Quote
Reply

Go BackWoWInterface » Featured Projects » Cladhaire's Mods » HOWTO: Integrate your addon with Clique (under Cataclysm/4.x)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off