Thread Tools Display Modes
12-31-14, 08:36 PM   #1
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Hyperlink Tooltip Help

This code has been around for a while and (first found it with NeavUI) but it seems to wrk for most item links except battle pets is there something im missing? Does a battle pet link have it own link style?

In this first image you will notice the mouseover is working. ( I also have fstack enabled to see what the difference in links are)


In this second image I linked a battle pet in the "say" channel and no tooltip. (again fstack is enabled)


Here is the current code I am using:
Code:
		local _G = getfenv(0)
		local orig1, orig2 = {}, {}
		local GameTooltip = GameTooltip

		local linktypes = {
			achievement  = true,
			enchant      = true,
			glyph        = true,
			item         = true,
			instancelock = true,
			quest        = true,
			spell        = true,
			talent       = true,
			unit         = true,
		}

		local function OnHyperlinkEnter(frame, link, ...)
			local linktype = link:match('^([^:]+)')
			if (linktype and linktypes[linktype]) then
				GameTooltip:SetOwner(ChatFrame1, 'ANCHOR_CURSOR', 0, 20)
				GameTooltip:SetHyperlink(link)
				GameTooltip:Show()
			else
				GameTooltip:Hide()
			end

			if (orig1[frame]) then 
				return orig1[frame](frame, link, ...) 
			end
		end

		local function OnHyperlinkLeave(frame, ...)
			GameTooltip:Hide()

			if (orig2[frame]) then 
				return orig2[frame](frame, ...) 
			end
		end

		local function EnableItemLinkTooltip()
			for _, v in pairs(CHAT_FRAMES) do
				local chat = _G[v]
				if (chat and not chat.URLCopy) then
					orig1[chat] = chat:GetScript('OnHyperlinkEnter')
					chat:SetScript('OnHyperlinkEnter', OnHyperlinkEnter)

					orig2[chat] = chat:GetScript('OnHyperlinkLeave')
					chat:SetScript('OnHyperlinkLeave', OnHyperlinkLeave)
					chat.URLCopy = true
				end
			end
		end
		hooksecurefunc('FCF_OpenTemporaryWindow', EnableItemLinkTooltip)
		EnableItemLinkTooltip()
I noticed in the code that linktypes does not have battlepet or any reference to pets so im thinking that might be my issue but what name would I use to get this to work?

Thanks
Coke
  Reply With Quote
01-01-15, 12:34 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Battle pets have their own tooltip object; they don't use the GameTooltip at all. Battle pet abilities, garrison followers, follower abilities, and missions also have their own tooltips objects. You can see how the default UI handles those here, though really it would be a lot easier to just call the click function on mouseover instead of recreating it:

Code:
chat:HookScript('OnHyperlinkEnter', ChatFrame_OnHyperlinkShow)
If you wanted to filter out certain types of links, and/or not have it treat "mouseover while shift is down" as a shift-click, then this would still be simpler:

Code:
local linktypes = {
	-- These use GameTooltip:
	achievement    = true,
	enchant        = true,
	glyph          = true,
	item           = true,
	instancelock   = true,
	quest          = true,
	spell          = true,
	talent         = true,
	unit           = true,
	-- This uses FloatingBattlePetTooltip:
	battlepet      = true,
	-- This uses FloatingPetBattleAbilityTooltip:
	battlePetAbil = true,
	-- This uses FloatingGarrisonFollowerTooltip:
	garrfollower  = true,
	-- This uses FloatingGarrisonFollowerAbilityTooltip:
	garrfollowerability = true,
	-- This uses FloatingGarrisonMissionTooltip:
	garrmission   = true,
}

local function OnHyperlinkEnter(frame, link, text)
	local linkType = strsplit(":", link)
	if linktypes[linktype] and not IsModifiedClick() then
		ChatFrame_OnHyperlinkShow(frame, link, text, "LeftButton")
	end
end

chat:HookScript('OnHyperlinkEnter', OnHyperlinkEnter)
Remember to update your OnHyperlinkLeave script to also hide those additional tooltip objects.

Also you can just use HookScript instead of manually storing and replacing and calling the original script. If there is no original script then HookScript behaves exactly like SetScript.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 01-01-15 at 12:50 AM.
  Reply With Quote
01-01-15, 09:56 AM   #3
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Phanx View Post
Code:
chat:HookScript('OnHyperlinkEnter', ChatFrame_OnHyperlinkShow)
The above code works when I add it to my "local function ModChat(self)" but the whole point of the "mouseover tooltip is to have it show and hide with mouseover, this shows the tooltip but then you need to click the x to close it.

Originally Posted by Phanx View Post
If you wanted to filter out certain types of links, and/or not have it treat "mouseover while shift is down" as a shift-click, then this would still be simpler:

Code:
local linktypes = {
	-- These use GameTooltip:
	achievement    = true,
	enchant        = true,
	glyph          = true,
	item           = true,
	instancelock   = true,
	quest          = true,
	spell          = true,
	talent         = true,
	unit           = true,
	-- This uses FloatingBattlePetTooltip:
	battlepet      = true,
	-- This uses FloatingPetBattleAbilityTooltip:
	battlePetAbil = true,
	-- This uses FloatingGarrisonFollowerTooltip:
	garrfollower  = true,
	-- This uses FloatingGarrisonFollowerAbilityTooltip:
	garrfollowerability = true,
	-- This uses FloatingGarrisonMissionTooltip:
	garrmission   = true,
}

local function OnHyperlinkEnter(frame, link, text)
	local linkType = strsplit(":", link)
	if linktypes[linktype] and not IsModifiedClick() then
		ChatFrame_OnHyperlinkShow(frame, link, text, "LeftButton")
	end
end

chat:HookScript('OnHyperlinkEnter', OnHyperlinkEnter)
Tried this also and nothing happened no tooltip show or anything.

Originally Posted by Phanx View Post
Remember to update your OnHyperlinkLeave script to also hide those additional tooltip objects.
Again tried this and got nothing.

So this is what I tried and didn't get to work:

Code:
                local _G = getfenv(0)
		local orig1, orig2 = {}, {}

		local linktypes = {
			-- These use GameTooltip:
			achievement    = true,
			enchant        = true,
			glyph          = true,
			item           = true,
			instancelock   = true,
			quest          = true,
			spell          = true,
			talent         = true,
			unit           = true,
			-- This uses FloatingBattlePetTooltip:
			battlepet      = true,
			-- This uses FloatingPetBattleAbilityTooltip:
			battlePetAbil = true,
			-- This uses FloatingGarrisonFollowerTooltip:
			garrfollower  = true,
			-- This uses FloatingGarrisonFollowerAbilityTooltip:
			garrfollowerability = true,
			-- This uses FloatingGarrisonMissionTooltip:
			garrmission   = true,
		}

		local function OnHyperlinkEnter(frame, link, ...)
			
			for _, tooltip in pairs({	
				'GameTooltip',
				'FloatingBattlePetTooltip',
				'FloatingPetBattleAbilityTooltip',
				'FloatingGarrisonFollowerTooltip',
				'FloatingGarrisonFollowerAbilityTooltip',
				'FloatingGarrisonMissionTooltip',			
			}) do
			        local linktype = link:match('^([^:]+)')
			        if (linktype and linktypes[linktype]) then				
					tooltip:SetOwner(ChatFrame1, 'ANCHOR_CURSOR', 0, 20)
					tooltip:SetHyperlink(link)
					tooltip:Show()				
				else
					tooltip:Hide()
				end
			end

			if (orig1[frame]) then 
				return orig1[frame](frame, link, ...) 
			end
		end

		local function OnHyperlinkLeave(frame, ...)
			for _, tooltip in pairs({		
				'GameTooltip',
				'FloatingBattlePetTooltip',
				'FloatingPetBattleAbilityTooltip',
				'FloatingGarrisonFollowerTooltip',
				'FloatingGarrisonFollowerAbilityTooltip',
				'FloatingGarrisonMissionTooltip',			
			}) do
				tooltip:Hide()
			end
			
			if (orig2[frame]) then 
				return orig2[frame](frame, ...) 
			end
		end

		local function EnableItemLinkTooltip()
			for _, v in pairs(CHAT_FRAMES) do
				local chat = _G[v]
				if (chat) then
					orig1[chat] = chat:GetScript('OnHyperlinkEnter')
					chat:HookScript('OnHyperlinkEnter', OnHyperlinkEnter)

					orig2[chat] = chat:GetScript('OnHyperlinkLeave')
					chat:HookScript('OnHyperlinkLeave', OnHyperlinkLeave)
				end
			end
		end
		hooksecurefunc('FCF_OpenTemporaryWindow', EnableItemLinkTooltip)
		EnableItemLinkTooltip()
Am I looking at this totally wrong?

Coke
  Reply With Quote
01-01-15, 10:31 AM   #4
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
so I figured it out (kinda on my own :P)

in Phanx's original code the linkType the T was no capitalized in the function code so it was not finding the table.
Code:
		local linktypes = {
			-- These use GameTooltip:
			achievement    = true,
			enchant        = true,
			glyph          = true,
			item           = true,
			instancelock   = true,
			quest          = true,
			spell          = true,
			talent         = true,
			unit           = true,
			-- This uses FloatingBattlePetTooltip:
			battlepet      = true,
			-- This uses FloatingPetBattleAbilityTooltip:
			battlePetAbil = true,
			-- This uses FloatingGarrisonFollowerTooltip:
			garrfollower  = true,
			-- This uses FloatingGarrisonFollowerAbilityTooltip:
			garrfollowerability = true,
			-- This uses FloatingGarrisonMissionTooltip:
			garrmission   = true,
		}

		local function OnHyperlinkEnter(frame, link, text)
			local linkType = strsplit(":", link)
			if linktypes[linkType] and not IsModifiedClick() then
				ChatFrame_OnHyperlinkShow(frame, link, text, "LeftButton")
			end
		end	
		
		local function OnHyperlinkLeave(frame, link, text)
			local linkType = strsplit(":", link)
			if linktypes[linkType] and not IsModifiedClick() then
				ChatFrame_OnHyperlinkShow(frame, link, text, "LeftButton")
			end
		end		
		
		local function ModChat(self)
			local chat = _G[self]


			chat:HookScript('OnHyperlinkEnter', OnHyperlinkEnter)
			chat:HookScript('OnHyperlinkLeave', OnHyperlinkLeave)
               end
Now mouse over shows and hides.

Coke

Last edited by cokedrivers : 01-01-15 at 10:43 AM.
  Reply With Quote
01-01-15, 10:47 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
That works too, but your last attempt didn't work because you were using some awful table-creating Frankenstein instead of the code I posted.

(1) When you use HookScript you should not manually capture and call the original script -- if you do that, it will be called twice, once before your script, and once from inside your script. If the original method toggles something, then calling it twice is like not calling it at all.

(2) You were looping over a list of string values and trying to call frame methods on them. This would generate a Lua error telling you exactly what and where the problem was. I know I've told you before -- go get an error display addon and use it!

(3) Even if you fixed #2, you'd still be attempting to show every tooltip object at the same time, which doesn't even make sense, because...

(4) You'd also be calling methods like SetOwner and SetHyperlink on objects that do not have those methods. Battle pet and garrison related tooltips are not GameTooltip-type objects, and cannot display arbitrary hyperlinks.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-01-15, 11:06 AM   #6
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
is there a SetPoint I can use to have the tooltip for the hyperlink show above my chatframe instead of above my mainmenubar?

I guess what im asking is were would I put this code:

Code:
	local i
	for i = 1, NUM_CHAT_WINDOWS do
               tooltip:SetPoint("TOP", _G["ChatFrame"..i], 0, 20)
        end
or ami totally off base here?

Coke
  Reply With Quote
01-01-15, 11:12 AM   #7
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Phanx View Post
(2) You were looping over a list of string values and trying to call frame methods on them. This would generate a Lua error telling you exactly what and where the problem was. I know I've told you before -- go get an error display addon and use it!
I do have Bugger and Bugsack installed an have them on at all times. I just didn't post the errors because like you posted in [4] it was throwing errors for SetOwner and Hide.

And believe it or not Phanx I listen to everything you have to say on coding, It might not sink in for the first few attempts or tries but in the end all my code seems to have the Phanx Seal of Approval because it is how you have written it.

Coke
  Reply With Quote
01-01-15, 11:57 AM   #8
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Just found out you need to add:
Code:
currency	   = true,
to the linktypes table if you would like to see your Apex Crystals and your Fragments Tooltips.

Coke
  Reply With Quote
01-01-15, 12:03 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by cokedrivers View Post
is there a SetPoint I can use to have the tooltip for the hyperlink show above my chatframe instead of above my mainmenubar?
You can use SetPoint, but you have to use SetOwner first with "ANCHOR_NONE", eg.

Code:
tooltip:SetOwner(parentFrame, "ANCHOR_NONE")
tooltip:SetPoint("BOTTOM", parentFrame, "TOP", 10, 0)
Note that only applies to the GameTooltip; the other tooltip-like frames don't have SetOwner, so you should just be able to SetPoint them (but don't forget to ClearAllPoints first)... if it looks/acts oddly, check the default UI code to see what it does when showing those frames.

Also, you shouldn't use Bugger and BugSack at the same time -- they both do the same thing. Pick the one you prefer, and get rid of the othe one.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-14-15, 07:34 PM   #10
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 758
Hey Phanx, coud you please post a final coude of this that works?
I'd realy like to see Battele Pet Tooltips on hoover and all tooltips shoud be anchored on top of my chatframe. Also any way to make it work with TipTac?
I have tryed to get something to work with the things posted here but no chance


I'm currently using this:
Lua Code:
  1. local _, LinkHover = ...
  2.  
  3. LinkHover.show = {
  4.     ["achievement"]  = true,
  5.     ["enchant"]      = true,
  6.     ["glyph"]        = true,
  7.     ["item"]         = true,
  8.     ["instancelock"] = true,
  9.     ["quest"]        = true,
  10.     ["spell"]        = true,
  11.     ["talent"]       = true,
  12.     ["unit"]         = true,
  13. }
  14.  
  15. function LinkHover:OnHyperlinkEnter(frame, linkData, link)
  16.     if self.show[linkData:match("^(.-):")] then
  17.         ShowUIPanel(GameTooltip)
  18.         GameTooltip:SetOwner(WorldFrame, "ANCHOR_BOTTOMLEFT", 30, 310)
  19.         GameTooltip:SetHyperlink(link)
  20.         GameTooltip:Show()
  21.     end
  22. end
  23.  
  24. function LinkHover:OnHyperlinkLeave(frame, linkData, link)
  25.     if self.show[linkData:match("^(.-):")] then
  26.         HideUIPanel(GameTooltip)
  27.     end
  28. end
  29.  
  30. function LinkHover:registerFrame(frame)
  31.     frame:SetScript("OnHyperlinkEnter", function(...) self:OnHyperlinkEnter(...) end)
  32.     frame:SetScript("OnHyperlinkLeave", function(...) self:OnHyperlinkLeave(...) end)
  33. end
  34.  
  35. function LinkHover:init()
  36.     self.eventframe = CreateFrame("Frame")
  37.     self.eventframe:RegisterEvent("GUILDBANKFRAME_OPENED")
  38.     self.eventframe:SetScript("OnEvent",
  39.         function(...)
  40.             self:registerFrame(GuildBankMessageFrame)
  41.             self.eventframe:UnregisterEvent("GUILDBANKFRAME_OPENED")
  42.             self.registerFrame = nil
  43.         end
  44.     )
  45.     local i
  46.     for i = 1, NUM_CHAT_WINDOWS do
  47.         self:registerFrame(_G["ChatFrame"..i])
  48.     end
  49. end
  50.  
  51. LinkHover:init()
  52. LinkHover.init = nil
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote
01-14-15, 08:09 PM   #11
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Tonyleila View Post
Hey Phanx, coud you please post a final coude of this that works?
It's not my code, why is it my job to post a working version of it?

Originally Posted by Tonyleila View Post
Also any way to make it work with TipTac?
TipTac just modifies the appearance of tooltips. It shouldn't have any effect on showing or hiding tooltips.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-14-15, 09:47 PM   #12
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 758
Originally Posted by Phanx View Post
It's not my code, why is it my job to post a working version of it?
Because you are such a warm-hearted talented and smart person and your code is always awesome!
...and its also not OP's code and I knew you woud read it :P
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote
01-16-15, 03:02 AM   #13
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Tonyleila View Post
Because you are such a warm-hearted talented and smart person and your code is always awesome!
I don't know about that first adjective... but here you go, totally untested.

Code:
local showLinkType = {
	-- Normal tooltip things:
	achievement  = true,
	enchant      = true,
	glyph        = true,
	item         = true,
	instancelock = true,
	quest        = true,
	spell        = true,
	talent       = true,
	unit         = true,
	-- Special tooltip things:
	battlepet           = false,
	battlePetAbil       = false,
	garrfollowerability = false,
	garrfollower        = false,
	garrmission         = false,
}

local function OnHyperlinkEnter(frame, link, text)
	local normal = showLinkType[linkData:match("^(.-):")]
	if normal == true then
		GameTooltip:SetOwner(WorldFrame, "ANCHOR_BOTTOMLEFT", 30, 310)
		GameTooltip:SetHyperlink(link)
		GameTooltip:Show()
	elseif normal == false then
		-- Uses a special tooltip, just let the default function handle it.
		SetItemRef(link, text, "LeftButton", frame)
	end
end

local function OnHyperlinkLeave(frame, linkData, link)
	local normal = showLinkType[linkData:match("^(.-):")]
	if normal == true then
		GameTooltip:Hide()
	elseif normal == false then
		-- Uses a special tooltip, just let the default function handle it.
		SetItemRef(link, text, "LeftButton", frame)
	end
end

local function RegisterFrame(frame)
	frame:SetScript("OnHyperlinkEnter", OnHyperlinkEnter)
	frame:SetScript("OnHyperlinkLeave", OnHyperlinkLeave)
end

local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", function(self, event, name)
	if event == "PLAYER_LOGIN" then
		for i = 1, NUM_CHAT_FRAMES do
			RegisterFrame(_G["ChatFrame"..i])
		end
	end
	if GuildBankMessageFrame then
		RegisterFrame(GuildBankMessageFrame)
		self:UnregisterAllEvents()
		self:SetScript("OnEvent", nil)
		RegisterFrame = nil
	else
		self:RegisterEvent("ADDON_LOADED")
	end
end)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-16-15, 07:51 AM   #14
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 758
Thank you, but it gives this error and nothing is happening :S but the code is still awesome!

Code:
2x LinkHover\LinkHover-1.3.lua:52: 'for' limit must be a number
LinkHover\LinkHover-1.3.lua:52: in function <LinkHover\LinkHover.lua:50>

Locals:
Lua Code:
  1. local showLinkType = {
  2.     -- Normal tooltip things:
  3.     achievement  = true,
  4.     enchant      = true,
  5.     glyph        = true,
  6.     item         = true,
  7.     instancelock = true,
  8.     quest        = true,
  9.     spell        = true,
  10.     talent       = true,
  11.     unit         = true,
  12.     currency       = true,
  13.     -- Special tooltip things:
  14.     battlepet           = false,
  15.     battlePetAbil       = false,
  16.     garrfollowerability = false,
  17.     garrfollower        = false,
  18.     garrmission         = false,
  19. }
  20.  
  21. local function OnHyperlinkEnter(frame, link, text)
  22.     local normal = showLinkType[linkData:match("^(.-):")]
  23.     if normal == true then
  24.         GameTooltip:SetOwner(WorldFrame, "ANCHOR_BOTTOMLEFT", 30, 310)
  25.         GameTooltip:SetHyperlink(link)
  26.         GameTooltip:Show()
  27.     elseif normal == false then
  28.         -- Uses a special tooltip, just let the default function handle it.
  29.         SetItemRef(link, text, "LeftButton", frame)
  30.     end
  31. end
  32.  
  33. local function OnHyperlinkLeave(frame, linkData, link)
  34.     local normal = showLinkType[linkData:match("^(.-):")]
  35.     if normal == true then
  36.         GameTooltip:Hide()
  37.     elseif normal == false then
  38.         -- Uses a special tooltip, just let the default function handle it.
  39.         SetItemRef(link, text, "LeftButton", frame)
  40.     end
  41. end
  42.  
  43. local function RegisterFrame(frame)
  44.     frame:SetScript("OnHyperlinkEnter", OnHyperlinkEnter)
  45.     frame:SetScript("OnHyperlinkLeave", OnHyperlinkLeave)
  46. end
  47.  
  48. local f = CreateFrame("Frame")
  49. f:RegisterEvent("PLAYER_LOGIN")
  50. f:SetScript("OnEvent", function(self, event, name)
  51.     if event == "PLAYER_LOGIN" then
  52.         for i = 1, NUM_CHAT_FRAMES do
  53.             RegisterFrame(_G["ChatFrame"..i])
  54.         end
  55.     end
  56.     if GuildBankMessageFrame then
  57.         RegisterFrame(GuildBankMessageFrame)
  58.         self:UnregisterAllEvents()
  59.         self:SetScript("OnEvent", nil)
  60.         RegisterFrame = nil
  61.     else
  62.         self:RegisterEvent("ADDON_LOADED")
  63.     end
  64. end)
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote
01-16-15, 08:30 AM   #15
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
try NUM_CHAT_WINDOWS
  Reply With Quote
01-16-15, 08:36 AM   #16
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 758
Originally Posted by ObbleYeah View Post
try NUM_CHAT_WINDOWS
That maybe worked, I'm not shure cause it now gives this error instead:
Code:
9x LinkHover\LinkHover-1.4.lua:22: attempt to index global 'linkData' (a nil value)
LinkHover\LinkHover-1.4.lua:22: in function <LinkHover\LinkHover.lua:21>

Locals:
EDIT fixed by replacing link with linkData
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________

Last edited by Tonyleila : 01-16-15 at 08:50 AM.
  Reply With Quote
01-16-15, 08:56 AM   #17
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
like Phanx said further up, you need to use SetOwner

Lua Code:
  1. tooltip:SetOwner(parent, anchor)

you can find a list of anchors here:
http://wowprogramming.com/docs/widge...oltip/SetOwner

edit: you edited your post :P
  Reply With Quote
01-16-15, 08:59 AM   #18
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 758
Ok it works now for normal tooltips but gives error with Gnosis when trying too mouseover PetLinks,
When I disable Gnosis it gives error with BadBoy etc ...

So disabeling all AddOns give this error:
Code:
4x FrameXML\ItemRef.lua:252: ItemRefTooltip:SetHyperlink(): Unknown link type
[C]: in function `SetHyperlink'
FrameXML\ItemRef.lua:252: in function <FrameXML\ItemRef.lua:1>
...aceBlizzard_CombatLog\Blizzard_CombatLog.lua:3593: in function `SetItemRef'
LinkHover\LinkHover-1.4.lua:29: in function <LinkHover\LinkHover.lua:21>

Locals:
link = "|cff0070dd|Hbattlepet:183:25:3:1481:276:276:BattlePet-0-000003F5E154|h[Astraler Seelenhändler]|h|r"
text = nil
button = "LeftButton"
chatFrame = ChatFrame1 {
 0 = <userdata>
 isUninteractable = false
 flashTimer = 0
 isInitialized = 1
 mouseOutTime = 0
 tellTimer = 9420.223
 resizeButton = ChatFrame1ResizeButton {
 }
 buttonFrame = ChatFrame1ButtonFrame {
 }
 oldAlpha = 0
 channelList = <table> {
 }
 hasBeenFaded = true
 clickAnywhereButton = ChatFrame1ClickAnywhereButton {
 }
 isDocked = 1
 mouseInTime = 0
 editBox = ChatFrame1EditBox {
 }
 checkedGMOTD = true
 isLocked = true
 name = "All"
 buttonSide = "left"
 isStaticDocked = true
 zoneChannelList = <table> {
 }
 defaultLanguage = "Orcisch"
 messageTypeList = <table> {
 }
}
Code right now:
Lua Code:
  1. local showLinkType = {
  2.         -- Normal tooltip things:
  3.         achievement  = true,
  4.         enchant      = true,
  5.         glyph        = true,
  6.         item         = true,
  7.         instancelock = true,
  8.         quest        = true,
  9.         spell        = true,
  10.         talent       = true,
  11.         unit         = true,
  12.         currency       = true,
  13.         -- Special tooltip things:
  14.         battlepet           = false,
  15.         battlePetAbil       = false,
  16.         garrfollowerability = false,
  17.         garrfollower        = false,
  18.         garrmission         = false,
  19.     }
  20.      
  21.     local function OnHyperlinkEnter(frame, linkData, link)
  22.         local normal = showLinkType[linkData:match("^(.-):")]
  23.         if normal == true then
  24.             GameTooltip:SetOwner(ChatFrame1Tab, "ANCHOR_TOPLEFT", 30, 20)
  25.             GameTooltip:SetHyperlink(link)
  26.             GameTooltip:Show()
  27.         elseif normal == false then
  28.             -- Uses a special tooltip, just let the default function handle it.
  29.             SetItemRef(link, text, "LeftButton", frame)
  30.         end
  31.     end
  32.  
  33.     local function OnHyperlinkLeave(frame, linkData, link)
  34.         local normal = showLinkType[linkData:match("^(.-):")]
  35.         if normal == true then
  36.             GameTooltip:Hide()
  37.         elseif normal == false then
  38.             -- Uses a special tooltip, just let the default function handle it.
  39.             SetItemRef(link, text, "LeftButton", frame)
  40.         end
  41.     end
  42.      
  43.     local function RegisterFrame(frame)
  44.         frame:SetScript("OnHyperlinkEnter", OnHyperlinkEnter)
  45.         frame:SetScript("OnHyperlinkLeave", OnHyperlinkLeave)
  46.     end
  47.      
  48.     local f = CreateFrame("Frame")
  49.     f:RegisterEvent("PLAYER_LOGIN")
  50.     f:SetScript("OnEvent", function(self, event, name)
  51.         if event == "PLAYER_LOGIN" then
  52.             for i = 1, NUM_CHAT_WINDOWS do
  53.                 RegisterFrame(_G["ChatFrame"..i])
  54.             end
  55.         end
  56.         if GuildBankMessageFrame then
  57.             RegisterFrame(GuildBankMessageFrame)
  58.             self:UnregisterAllEvents()
  59.             self:SetScript("OnEvent", nil)
  60.             RegisterFrame = nil
  61.         else
  62.             self:RegisterEvent("ADDON_LOADED")
  63.         end
  64.     end)
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________

Last edited by Tonyleila : 01-16-15 at 09:01 AM.
  Reply With Quote
01-16-15, 10:23 AM   #19
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
I think the SetItemRef call in OnHyperlinkEnter should be this instead:
Code:
SetItemRef(linkData, link, "LeftButton", frame)
Shouldn't that SetItemRef call in OnHyperlinkLeave be this instead?
Code:
ItemRefTooltip:Hide()
  Reply With Quote
01-16-15, 10:46 AM   #20
Tonyleila
A Molten Giant
 
Tonyleila's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 758
Originally Posted by Vrul View Post
I think the SetItemRef call in OnHyperlinkEnter should be this instead:
Code:
SetItemRef(linkData, link, "LeftButton", frame)
This fixed it!


Shouldn't that SetItemRef call in OnHyperlinkLeave be this instead?
Code:
ItemRefTooltip:Hide()
I guess yes right now the Pet tooltip dosen't care about the the anchor and will just show up where I closed it last time. Coud you be more detailed where to add it to fix that?^^
__________________
Author of: LeilaUI and Aurora: Missing Textures
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Hyperlink Tooltip Help

Thread Tools
Display Modes

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