Thread Tools Display Modes
07-16-12, 11:29 AM   #1
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
Pass Click to Parent

Using the oUF Aura element, I want to pass the left click to the unit while keeping the OnEnter aura tooltip. Here is the relevant code that blizzard's CompactUnitFrame has.

https://github.com/tekkub/wow-ui-sou...Frame.xml#L119

https://github.com/tekkub/wow-ui-sou...rent.lua#L2310

Using oUF's PostCreateIcon to apply blizzard's method...

Lua Code:
  1. local function PostCreateIcon(Auras, button)
  2.     button:RegisterForClicks("LeftButtonUp")
  3.  
  4.     button:SetScript("OnClick", function(self, ...)
  5.         local parent = self:GetParent()
  6.         print(parent.__owner:GetName()) -- returns frameName_UnitButton1, etc
  7.  
  8.         parent.__owner:Click(...)  
  9.     end)
  10. end

This is blocked by the blizzardui and I'm looking for the correct way to implement it.
  Reply With Quote
07-16-12, 06:15 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I don't think there is a correct way; Blizzard's own code is not subject to the same restrictions as addons, so they can do anything they want, regardless of whether it's possible for addons to do the same thing.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
07-16-12, 08:16 PM   #3
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
Well that's no good. Can the Aura frame be completely transparent to the mouse? EnableMouse(false) doesn't help.

EDIT: EnableMouse(false) does work using 'PostUpdateIcon' instead of 'PostCreateIcon'

Last edited by Freebaser : 07-18-12 at 12:08 PM.
  Reply With Quote
07-17-12, 10:39 AM   #4
kaels
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 46
At a minimum, you will have to create the aura frames using a secure template. If you're not using a secure template, you can't execute protected functions like targeting. Making each of them with SecureUnitButtonTemplate would be simplest for targeting if you're just doing a few static indicators, but I think you need to use SecureAuraHeaderTemplate if you want the whole collection of auras to show/hide/sort properly. You then lose filtering capability.

And I haven't gotten around to my auras in oUF yet, so i don't know if it's even possible to do them with secure frames. You might need to write your own module.

There's an alternative approach, where you layer your auras under an array of (transparent) mouse-interactive secure unit frames, and you code each of the unit frames to display the tooltip for the aura underneath it. That would be horribly messy but you'd be able to retain sorting/filtering/etc.
  Reply With Quote
07-17-12, 05:25 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by kaels View Post
At a minimum, you will have to create the aura frames using a secure template. If you're not using a secure template, you can't execute protected functions like targeting. Making each of them with SecureUnitButtonTemplate would be simplest for targeting if you're just doing a few static indicators, but I think you need to use SecureAuraHeaderTemplate if you want the whole collection of auras to show/hide/sort properly. You then lose filtering capability.
Yeah, secure auras are useless on a unit frame IMO... who wants to see 40 tiny icons for mostly-irrelevant buffs in the middle of the screen? :/

Originally Posted by kaels View Post
And I haven't gotten around to my auras in oUF yet, so i don't know if it's even possible to do them with secure frames. You might need to write your own module.
You would need to write it yourself.

Originally Posted by kaels View Post
There's an alternative approach, where you layer your auras under an array of (transparent) mouse-interactive secure unit frames, and you code each of the unit frames to display the tooltip for the aura underneath it. That would be horribly messy but you'd be able to retain sorting/filtering/etc.
This would entail enabling an OnUpdate when OnEnter fired for the frame, and inside the OnUpdate, check the cursor position, calculate which aura icon slot (if any) the cursor was in, figure out which aura (if any) was shown in the slot, and show the tooltip if an aura was found there.

It would also mean that if you wanted your frame to have a visible backdrop, you'd need to create a separate frame to apply SetBackdrop to, since otherwise your backdrop would extend behind the auras, too.

Finally, this would mean you'd have a sizable region that was clickable as part of the unit frame, even though it was completely invisible because you didn't currently have 40 buffs (or however many you want to show).

All in all, I wouldn't recommend it. Unit frames should be limited to only displaying auras that are acutally important, and you should be able to recognize important auras by their icon, so tooltips are not really needed. If someone wants to see all of their buffs by their unit frame, they can install a custom buff addon and place it there themselves.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
07-18-12, 01:28 AM   #6
kaels
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 46
Originally Posted by Phanx View Post
Yeah, secure auras are useless on a unit frame IMO... who wants to see 40 tiny icons for mostly-irrelevant buffs in the middle of the screen? :/



You would need to write it yourself.



This would entail enabling an OnUpdate when OnEnter fired for the frame, and inside the OnUpdate, check the cursor position, calculate which aura icon slot (if any) the cursor was in, figure out which aura (if any) was shown in the slot, and show the tooltip if an aura was found there.

It would also mean that if you wanted your frame to have a visible backdrop, you'd need to create a separate frame to apply SetBackdrop to, since otherwise your backdrop would extend behind the auras, too.

Finally, this would mean you'd have a sizable region that was clickable as part of the unit frame, even though it was completely invisible because you didn't currently have 40 buffs (or however many you want to show).

All in all, I wouldn't recommend it. Unit frames should be limited to only displaying auras that are acutally important, and you should be able to recognize important auras by their icon, so tooltips are not really needed. If someone wants to see all of their buffs by their unit frame, they can install a custom buff addon and place it there themselves.
Well, my thought was that you can create as many secure frames as you like. So you'd have a layered structure:

1) Your normal unit frame, however you want to draw it
2) Your auras
3) An array of invisible secure frames with the same size/spacing as the auras, whose entire purpose in life is:
a) Relay clicks to the actual unit frame (you could wrap their OnClick to do this, to avoid messing with Clique)
b) Figure out which aura is under them and display its tooltip on mouseover (this is cosmetic, so you don't need to use secure code, so you can get information from the aura frames about their current position).

It would involve a lot of frames, obviously. You'd probably want to cap the number of displayed auras pretty low if you're doing this for a lot of units, but that really only applies to raidframes, and you don't want to display a whole ton of auras on raid frames anyway. But it would work acceptably well if you just wanted to show, say, up to 4 debuffs.

If you're doing it indicator-style (one aura displayed at a time per indicator, no moving/reanchoring), then it's even easier, because your clickable mini-frames can be your indicators, and then you don't even have to go fishing around trying to find where other frames are to decide which tooltip to show.

And obviously you don't want to do this for auras that are displayed outside the normally visible/clickable area of your unit frame. I was assuming the OP wanted to relay clicks for auras displayed on top of unit frames (e.g. for raid debuffs) - it's something I want to do as well, because as a healer I like to have tooltips for debuffs I don't recognize, but I also like not having to avoid the debuff area when I'm actually trying to heal/dispel the unit.
  Reply With Quote
07-18-12, 12:46 PM   #7
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
Edited my previous post that EnableMouse(false) does work using PostUpdateIcon, but obviously lose the tooltip.

I was assuming the OP wanted to relay clicks for auras displayed on top of unit frames (e.g. for raid debuffs)
Your assumption is correct.

I'm messing with "SecureActionButtonTemplate" in own aura element and It seems to work with this example.

Lua Code:
  1. local function PostCreateIcon(Auras, button)
  2.     local object = Auras.__owner
  3.  
  4.     button:SetAttribute("unit", object.unit)
  5.     button:SetAttribute("*type1", "target")
  6. end

I'm assuming this would work with Clique, if I added the necessary support code.
  Reply With Quote
07-18-12, 01:33 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by kaels View Post
1) Your normal unit frame, however you want to draw it
2) Your auras
3) An array of invisible secure frames with the same size/spacing as the auras, whose entire purpose in life is:
a) Relay clicks to the actual unit frame (you could wrap their OnClick to do this, to avoid messing with Clique)
b) Figure out which aura is under them and display its tooltip on mouseover (this is cosmetic, so you don't need to use secure code, so you can get information from the aura frames about their current position).
Creating an extra secure frame for every aura is completely unnecessary; just don't enable the mouse on anything other than the unit frame itself. Determining the cursor's location is trivial, just tedious.

Originally Posted by kaels View Post
... as a healer I like to have tooltips for debuffs I don't recognize ...
Which debuffs are important enough that you need to see them to do your job, but not important enough that you recognize them (either explicitly by their icon, or implicitly by context)?
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
07-19-12, 03:00 AM   #9
kaels
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 46
Originally Posted by Phanx View Post
Which debuffs are important enough that you need to see them to do your job, but not important enough that you recognize them (either explicitly by their icon, or implicitly by context)?
When I first go into new content, I don't know the icons by sight. I also don't PvP much, so I don't know what a lot of player ability icons are for classes I don't play.

It's particularly relevant with the new dispel CD in MoP.
  Reply With Quote
07-19-12, 03:07 AM   #10
kaels
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 46
Originally Posted by Freebaser View Post
Edited my previous post that EnableMouse(false) does work using PostUpdateIcon, but obviously lose the tooltip.


Your assumption is correct.

I'm messing with "SecureActionButtonTemplate" in own aura element and It seems to work with this example.

Lua Code:
  1. local function PostCreateIcon(Auras, button)
  2.     local object = Auras.__owner
  3.  
  4.     button:SetAttribute("unit", object.unit)
  5.     button:SetAttribute("*type1", "target")
  6. end

I'm assuming this would work with Clique, if I added the necessary support code.
It would work with Clique, but you're going to run into issues, because oUF's going to try to move those frames around in combat and taint them. If your auras are going to be secure frames, you need to either give them static anchors or handle them with a secure header (the latter being generally a bad idea as discussed above).

Originally Posted by Phanx
Creating an extra secure frame for every aura is completely unnecessary; just don't enable the mouse on anything other than the unit frame itself. Determining the cursor's location is trivial, just tedious.
I just didn't like the idea of running an OnUpdate script whenever the cursor was over a frame. The memory hit of extra frames seemed less bad than the CPU hit of having an OnUpdate running pretty much all the time (as a healer).
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Pass Click to Parent


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