View Single Post
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