WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Providing mouseover highlighting (https://www.wowinterface.com/forums/showthread.php?t=23087)

Barjack 04-30-09 12:20 PM

Providing mouseover highlighting
 
So, thought I'd ask people's thoughts on good ways to provide mouseover highlighting for various frames.

To start with, initially I was using the HIGHLIGHT layer of the unitframe itself. The problem with this was that any frames created on top of the unitframe (like, say, a health bar) would cover it, and I couldn't figure out a way to push the highlight texture higher up without SetFrameLevel. This seemed pretty hackish though and I noticed that if I tried to SetFrameLevel the unitframe itself I was getting taint issues. I guess maybe that function is protected to stop people stacking frames in the same visual space and using the frame level to determine which one is clicked? I'm no expert on this or anything, so I don't really know. Presumably just using SetFrameLevel on the health bars would be okay, but it's still pretty ugly.

So moving on to attempting a more "manual" solution, I'm currently just manually creating a new frame to hold the highlight texture. Code is as follows:
Code:

  ---- Highlight
  self.HighlightFrame = CreateFrame("Frame", nil, self)
  self.Highlight = self.HighlightFrame:CreateTexture(nil, "OVERLAY")
  self.Highlight:SetPoint("TOPLEFT", self.Health)
  self.Highlight:SetPoint("BOTTOMRIGHT", self.Power)
  self.Highlight:SetAlpha(0.6)
  self.Highlight:SetBlendMode('ADD')
  self.Highlight:SetTexture(texHighlight)
 
  self.Highlight:Hide()
  self:EnableMouse()
  local oldOnEnter = self:GetScript("OnEnter")
  local oldOnLeave = self:GetScript("OnLeave")
  self:SetScript("OnEnter", function(self, ...) self.Highlight:Show(); oldOnEnter(self, ...) end)
  self:SetScript("OnLeave", function(self, ...) self.Highlight:Hide(); oldOnLeave(self, ...) end)

I guess I should have expected it (I didn't), but of course there were already OnEnter and OnLeave scripts, so unless I wanted to lose tooltips and whatever other code may be there I had to call the old functions too. But of course, now they're being called from a non-secure context... I'm not sure if this matters, but I'm a little wary all the same considering my earlier taint problems.

I don't know if it even makes sense to try hooking the original functions instead, in order to keep it untainted, but even if it did make sense I don't know how to do that considering hooksecurefunc takes a string argument and all I know how to get is a reference.

But even more generally, I was wondering if anybody had experience doing this themselves and what techniques etc. they used. Thoughts/opinions/etc. welcome.

Gotai 04-30-09 04:23 PM

You can use frame:HookScript("scripttype", function) to securely hook an already existing script:

Code:

  self:HookScript("OnEnter", function(self, ...) self.Highlight:Show() end)

Barjack 04-30-09 08:29 PM

Quote:

Originally Posted by Gotai (Post 132428)
You can use frame:HookScript("scripttype", function) to securely hook an already existing script:

Code:

  self:HookScript("OnEnter", function(self, ...) self.Highlight:Show() end)

Aha, that's just about perfect then. Thanks a lot.

p3lim 05-01-09 05:34 AM

I do it a bit simpler in my raid layout.

http://github.com/p3lim/ouf_mini/blo...8/oUF_Mini.lua

You can add the show/hide directly into a function, because you set the scripts yourself anyways.


All times are GMT -6. The time now is 12:08 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI