Quantcast
Hyperlink Tooltip Change - WoWInterface
Thread Tools Display Modes
05-16-21, 04:14 PM   #1
Saspatoon
A Defias Bandit
Join Date: May 2021
Posts: 2
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:
Code:
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)
 end
 return origChatFrame_OnHyperlinkShow(...); -- (6)
end
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(...);
 end
end
function ShowTinfoilHat()
 ShowUIPanel(ItemRefTooltip);
 if (not ItemRefTooltip:IsVisible()) then
  ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE");
 end
 ItemRefTooltip:ClearLines();
 addLine("\124cff0070ddTinfoil Hat\124r", "Binds when equipped");
 ItemRefTooltip:AddDoubleLine("Head","Cloth",1,1,1,1,1,1);
 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();
end
  Reply With Quote
05-17-21, 02:48 AM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 817
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
  25.  
  26. for i = 1, NUM_CHAT_WINDOWS do
  27.     local cfn = format('ChatFrame%i',i)
  28.     local cf = _G[cfn]
  29.  
  30.     cf:HookScript("OnHyperlinkEnter",chatHoverIn)
  31.     cf:HookScript("OnHyperlinkLeave",chatHoverOut)
  32. end
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
05-17-21, 07:55 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,845
Are you talking about the standalone tooltip frame that opens when you click a link in chat? That is called the ItemRefTooltip.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
05-17-21, 11:14 PM   #4
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 817
My fault. Didn't read the part with tooltip after shift clicking.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
05-18-21, 05:51 PM   #5
Saspatoon
A Defias Bandit
Join Date: May 2021
Posts: 2
Originally Posted by Seerah View Post
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
  Reply With Quote

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

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