ChatlinkTooltip/ChatlinkTooltip.lua

35 lines
934 B
Lua
Raw Permalink Normal View History

2023-04-24 19:31:56 +00:00
local function showTooltip(self, linkData)
local linkType = string.split(":", linkData)
if linkType == "item"
or linkType == "spell"
or linkType == "enchant"
or linkType == "quest"
or linkType == "talent"
or linkType == "glyph"
or linkType == "unit"
or linkType == "achievement" then
GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
GameTooltip:SetHyperlink(linkData)
GameTooltip:Show()
end
end
local function hideTooltip()
GameTooltip:Hode()
end
local function setOrHookHandler(frame, script, func)
if frame:GetScript(script) then
frame:HookScript(script, func)
else
frame:SetScript(script, func)
end
end
for i = 1, NUM_CHAT_WINDOWS do
local frame = getglobal("ChatFrame"..i)
if frame then
setOrHookHandler(frame, "OnHyperlinkEnter", showTooltip)
setOrHookHandler(frame, "OnHyperlinkLeave", hideTooltip)
end
end