Change the alpha on a frame/subframes in response to mouse
This snippet will change the alpha of a frame (and all of it's sub-children due to the way alpha works) depending on whether or not the mouse is over the frame or not. See http://wowprogramming.com/forums/development/300 for a more in-depth discussion of this problem and solution.
Snippet
function SetActiveInactive(frame, active, inactive)
frame:SetScript("OnUpdate", function(self, elapsed)
local current = GetMouseFocus()
-- Scan through the parent chain
while current ~= nil do
if current == frame then
frame:SetAlpha(active)
return
end
current = current:GetParent()
end
frame:SetAlpha(inactive)
end)
end
-- Example usage: SetActiveInactive(PlayerFrame, 1.0, 0.7)
Posted by jnwhiteh at Sat, 05 Jun 2010 17:26:56 +0000