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.