I’m creating an addon and i have an issue with frame anchors. I want to move the GameTooltip frame which appears at the bottom right corner when you mouseover a player or a spell.
If a GameTooltip is on screen, and i run this code, the frame move to the center of the screen. But the anchor is not memorised, and the next GameTooltip frame will pop back in the bottom right corner.
I searched in the lua files of this frame and there is a function which (i guess) control the anchor of the GameTooltip frame when it’s created :
GameTooltip_SetDefaultAnchor (tooltip, parent)
But i don’t know how to permenatly change this function to put this frame to another place of the screen. I read some posts about hooking functions but i didn’t understand how it works (i’m learning myselsf, like most of us i think).
I don’t know much about lua myself, but I found this to move my tooltip to the location I want.
function GameTooltip_SetDefaultAnchor(tooltip,parent)
tooltip:SetOwner(parent,"ANCHOR_NONE")
tooltip:SetPoint("BOTTOMRIGHT","UIParent","BOTTOMRIGHT",0,10)
tooltip.default=1 end
Yes, that’s the function i found.
But this function is used each time a GameTooltip is created.
I tried hooking this function but i get an error about the parent in the SetOwner line… That’s why i came hear for help.
I tried to post-hooking by doing this (TracerFunction is the table where i put all my functions) :
function TracerFunction:postHook(tooltip, parent)
tooltip:ClearAllPoints();
tooltip:SetPoint("CENTER","UIParent","CENTER",0,0);
end
hooksecurefunc("GameTooltip_SetDefaultAnchor", TracerFunction.postHook);
But, when i mouseover a spell on my actionbars, all my spells move…
Update !
I was creating tooltips for another thing and i go back on this problem. I change a bit the code and it’s finnaly working :
function TracerFunction:postHook()
GameTooltip:SetOwner(UIParent, "ANCHOR_NONE");
GameTooltip:SetPoint("BOTTOMRIGHT",QuickJoinToastButton,"TOPLEFT",0,0);
end
hooksecurefunc("GameTooltip_SetDefaultAnchor", TracerFunction.postHook);
Now, there is an issue with another addon, but it’s another problem ^^
Your code was malfunctioning because you are using a function defined with the colon operator as a callback to hooksecurefunc. TracerFunction:postHook(tooltip, parent) is essentially the same as TracerFunction.postHook(self, tooltip, parent). So when the hook function is called it ends up with the tooltip frame in the self variable, the parent frame in the tooltip variable and nil in the parent variable. Then you proceed to call ClearAllPoints and SetPoint, which at this point don’t target “tooltip” as you expected but “parent”. So it reanchors the entire parent frame of what you’re mousing over. Hope that makes sense.
OK !!!
Thanks for the explanation. In fact, I only use the colon operator in my program because i don’t need arguments in most of my functions. So, i never had this problem before.