WoWInterface (
-   Lua/XML Help (
-   -   Hyperlink Tooltip Change (

Saspatoon 05-16-21 04:14 PM

Hyperlink Tooltip Change
WoW Classic 1.3.7 / TBC

Hey guys, I am working on an addon that changes the tooltip of particular item ID's and adds a description to them. I have it working for items that you hover over in your bags, but when you Shift-Click an item into the chat window (Or click an item you recently looted from mobs) the hyper-link tooltip seems to be different from the bags version.

I couldn't find anything other than the WoWAPI website example, and the example doesnt even seem to work anymore. Is this still possible? or did they remove our ability to change hyperlink tooltips?

The Code i tried to use from the WoW Api Hooking functions page, didnt work out right and even after playing with it trying to make it work i had no success. Thank you

Code from the WoWApi Example:

local origChatFrame_OnHyperlinkShow = ChatFrame_OnHyperlinkShow; -- (1)
ChatFrame_OnHyperlinkShow = function(...) -- (2)
 local chatFrame, link, text, button = ...; -- (3)
 if type(text) == "string" and text:match("%[Tinfoil Hat%]") and not IsModifiedClick() then --(4)
  return ShowTinfoilHat(); -- (5)
 return origChatFrame_OnHyperlinkShow(...); -- (6)
print("Click me: \124cff0070dd\124Hitem:8191:0:0:0:0:0:0:0:0:1\124h[Tinfoil Hat]\124h\124r"); -- (7)

-- The code below deals mostly with the tinfoil hat tooltip and is irrelevant to hooking
local function addLine(a, ...)
 if a then
  return ItemRefTooltip:AddLine(a,1,1,1,1), addLine(...);
function ShowTinfoilHat()
 if (not ItemRefTooltip:IsVisible()) then
  ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE");
 addLine("\124cff0070ddTinfoil Hat\124r", "Binds when equipped");
 addLine("10 Armor", "-10 Intellect", "+10 Spirit", (UnitLevel("player") < 10) and "\124cffff0000Requires Level 10\124r" or "Requires Level 10");
 addLine("\124cff00ff00Equip: Hides the wearer's profile from the Armory.\124r");
 addLine("\124cff00ff00Equip: Allows the wearer to see \"the truth.\" May lead to an incontrollable urge to share \"the truth\" with others.\124r");
 addLine("\124cff00ff00Use: Grants the wearer immunity to all forms of mind control for the next 10 seconds... or does it?\124r");
 addLine("\124cffffd517On behalf of the International Gnomish Conspiracy, I've got to inform you that we're almost out of tinfoil.\124r");
 ItemRefTooltip:Show(); ItemRefTooltip:Show();

Rilgamon 05-17-21 02:48 AM

Perhaps you can take a look at OnHyperlinkEnter, OnHyperlinkLeave?

Lua Code:
  1. local function chatHoverIn(cf, link, text)
  2.     local typ = string.match(link, "^(.-):")
  3. --[[    print(typ,link)
  4.     local tbl = { strsplit(":", link) }
  5.     for k,v in pairs(tbl) do
  6.         print(v)
  7.     end
  8. ]]--
  9.     if(typ == "item" or typ == "enchant" or typ == "spell" or typ == "quest" or typ == "currency") then
  10.         GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
  11.         GameTooltip:SetHyperlink(link)
  12.         ShowUIPanel(GameTooltip)
  13.     elseif(typ == "player") then
  14.         local typ, name = string.match(link, "^(.-):(.*):(.*):")
  15.         if(name) then
  16.             GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
  17.             GameTooltip:SetUnit(name)
  18.             ShowUIPanel(GameTooltip)
  19.         end    
  20.     end
  21. end
  22. local function chatHoverOut(cf, link, text)
  23.     HideUIPanel(GameTooltip)
  24. end
  26. for i = 1, NUM_CHAT_WINDOWS do
  27.     local cfn = format('ChatFrame%i',i)
  28.     local cf = _G[cfn]
  30.     cf:HookScript("OnHyperlinkEnter",chatHoverIn)
  31.     cf:HookScript("OnHyperlinkLeave",chatHoverOut)
  32. end

Seerah 05-17-21 07:55 PM

Are you talking about the standalone tooltip frame that opens when you click a link in chat? That is called the ItemRefTooltip.

Rilgamon 05-17-21 11:14 PM

My fault. Didn't read the part with tooltip after shift clicking.

Saspatoon 05-18-21 05:51 PM


Originally Posted by Seerah (Post 339149)
Are you talking about the standalone tooltip frame that opens when you click a link in chat? That is called the ItemRefTooltip.

Yes!! Thank you. I figured it out right away with ItemRefTooltip. Awesome. Appreciated

All times are GMT -6. The time now is 08:01 PM.

vBulletin © 2022, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI