Thread Tools Display Modes
08-18-11, 06:57 PM   #1
crumsack
A Murloc Raider
Join Date: Aug 2011
Posts: 8
Question Tooltip Repositioning and Returning

Hello WoW Interface community, this is my first post here, so bear with me. To start off by saying, I did search for this topic and could not find one with my issue. Anyways, I am putting together my own UI and im using Bagnon in the process. One of the features I liked about TukUI is how he made the tooltip switch to the top of the bags frame when open and return back to default. I am trying to pull that same thing off but with Bagnon and SpartanUI. Im still a bit new to LUA so this is the place I thought I might give a go.

So far I have this:

Code:
hooksecurefunc(GameTooltip,"SetPoint",function(tooltip,point,parent,rpoint) -- fix GameTooltip offset
	if (point == "BOTTOMRIGHT" and parent == "UIParent" and rpoint == "BOTTOMRIGHT") then
		tooltip:ClearAllPoints();
		tooltip:SetPoint("BOTTOMRIGHT","SpartanUI","TOPRIGHT",0,10);
	else
		tooltip:SetPoint("BOTTOMRIGHT","BagnonFrameinventory","TOPRIGHT",0,10);
	end
end);
And it works, but when I close Bagnon, the tooltip stays where it was on top of bagnon and doesn't return.

Any of you peeps out there might beable to give me a hint?

Thanks.

Last edited by crumsack : 08-18-11 at 09:07 PM. Reason: Added question icon.
  Reply With Quote
08-19-11, 09:02 AM   #2
crumsack
A Murloc Raider
Join Date: Aug 2011
Posts: 8
Nobody knows?
  Reply With Quote
08-19-11, 09:44 AM   #3
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Okay well, this code needs a little makeover.

First of all, while your hooking of the function is good in most cases, there is a better method to use in this case, namely hooking GameTooltip_SetDefaultAnchor. Secondly, you shouldn't look for which is the current point; you should set it regardless, and only change it if the bags are shown. Thirdly, your anchor name doesn't need any brackets around it. Which turns into something like this:

Code:
hooksecurefunc("GameTooltip_SetDefaultAnchor", function(self, parent)
	if BagnonFrameinventory:IsShown() then
		self:SetPoint("BOTTOMRIGHT", BagnonFrameinventory, "TOPRIGHT", 0, 10)
	else
		self:SetPoint("BOTTOMRIGHT", SpartanUI, "TOPRIGHT", 0, 10)
	end
end)
Also, make sure that the anchor's names are spelt correctly.
  Reply With Quote
08-19-11, 09:49 AM   #4
crumsack
A Murloc Raider
Join Date: Aug 2011
Posts: 8
Thank you very much! I will test this and see if it works. And yes the "BagnonFrameinventory" is correct as thats what /framestack says about it when I mouseover it xD
  Reply With Quote
08-19-11, 09:51 AM   #5
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Good, it just looked a little strange to me with the 'i' not being capitalised.
  Reply With Quote
08-19-11, 09:53 AM   #6
crumsack
A Murloc Raider
Join Date: Aug 2011
Posts: 8
Well it works like I want it too, but the only thing is it starts off in the default game position, when I open Bagnon, it goes to the top like I want, then returns to the top of SpartanUI like I want it. Just that starting point is not correct. Anything I need to add?

And yea, that bugged me too about the "i" thing. Might be a type on the Bagnon creators part.
  Reply With Quote
08-19-11, 10:04 AM   #7
crumsack
A Murloc Raider
Join Date: Aug 2011
Posts: 8
I tried to add self:ClearAllPoints before both and I thought that might work but didn't.
  Reply With Quote
08-19-11, 10:08 AM   #8
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Strange. Try this:

Code:
hooksecurefunc("GameTooltip_SetDefaultAnchor", function(self, parent)
	self:SetOwner(parent, "ANCHOR_NONE")
	if BagnonFrameinventory:IsShown() then
		self:SetPoint("BOTTOMRIGHT", BagnonFrameinventory, "TOPRIGHT", 0, 10)
	else
		self:SetPoint("BOTTOMRIGHT", SpartanUI, "TOPRIGHT", 0, 10)
	end
end)
Or this:

Code:
hooksecurefunc("GameTooltip_SetDefaultAnchor", function(self, parent)
	if BagnonFrameinventory:IsShown() then
		self:SetPoint("BOTTOMRIGHT", BagnonFrameinventory, "TOPRIGHT", 0, 10)
		return
	end
	self:SetPoint("BOTTOMRIGHT", SpartanUI, "TOPRIGHT", 0, 10)
end)
  Reply With Quote
08-19-11, 10:13 AM   #9
crumsack
A Murloc Raider
Join Date: Aug 2011
Posts: 8
Woot! I figured it out Haha! (thats a first)
Nevrmind xD I screwd up, it makes me laggy xD

Code:
		hooksecurefunc(GameTooltip,"SetPoint", function(self, point, parent, rpoint)
			if (point == "BOTTOMRIGHT" and parent == "UIParent" and rpoint == "BOTTOMRIGHT") then
				self:ClearAllPoints();
				self:SetPoint("BOTTOMRIGHT","SpartanUI","TOPRIGHT",0,10);
			elseif BagnonFrameinventory:IsShown() then
				self:SetPoint("BOTTOMRIGHT", BagnonFrameinventory, "TOPRIGHT", 0, 10)
			else
				self:SetPoint("BOTTOMRIGHT", SpartanUI, "TOPRIGHT", 0, 10)
			end
		end)

I will try yours.

Last edited by crumsack : 08-19-11 at 10:18 AM.
  Reply With Quote
08-19-11, 10:17 AM   #10
crumsack
A Murloc Raider
Join Date: Aug 2011
Posts: 8
Well both those sorta work, but still do the same as before on your first post. I made it work with my technique, but when I hover over icons it makes me like glitchy xD


... so Im still stuck haha.
  Reply With Quote
08-19-11, 10:32 AM   #11
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Not sure then, I'll leave it to someone else.
  Reply With Quote
08-19-11, 10:33 AM   #12
crumsack
A Murloc Raider
Join Date: Aug 2011
Posts: 8
Thank you very much for the help!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Tooltip Repositioning and Returning


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