Quantcast
Tooltip hook stopped working in latest patch? - WoWInterface
Thread Tools Display Modes
10-06-22, 09:19 AM   #1
Yocote
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 5
Question Tooltip hook stopped working in latest patch?

Is anyone aware of any changes in how tooltip hooking works in yesterday's DragonFlight patch (2022-10-04, patch 45969)? One of my addons that adds a few lines to item tooltips has unexpecetdly stopped working (it worked in earlier dragonflight beta patches). Has there been a change? Or alternatively, can anyone show a minimalistic example of addon code that adds a line to an item tooltip?
  Reply With Quote
10-06-22, 10:07 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,633
Tooltips have been reworked with C_TooltipInfo but, from what I've read so far, if your tooltip uses "GameTooltipTemplate" instead of "SharedTooltipTemplate" you should be (mostly) OK... for the time being.

The info hasn't been added to WowPedia yet which is understandable being new and all.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
10-06-22, 10:50 AM   #3
Yocote
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 5
Thanks for the info! I am not creating my own tooltip though, but adding extra lines to the system "GameTooltip" (and a few related ones), using code similar to this to hook in my code:

Lua Code:
  1. local tooltips = {
  2.   GameTooltip,
  3.   ItemRefTooltip,
  4.   ShoppingTooltip1,
  5.   ShoppingTooltip2,
  6. }
  7.  
  8. function events:PLAYER_LOGIN()
  9.   for i=1,#tooltips do
  10.     tooltips[i]:HookScript("OnTooltipSetItem", function(tt)
  11.       MyTooltipAddon:ProcessTip(tt)
  12.     end)
  13.   end
  14. end

What I observe is that my "MyTooltipAddon:ProcessTip" method is no longer being called at all since this patch. The hooking code in the PLAYER_LOGIN event handler is called, and no errors are raised there, but the hooks are just never called, as if HookScript silently no longer does anything anymore.
  Reply With Quote
10-06-22, 11:27 AM   #4
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
I've found OnTooltipSetItem is not being called for GameTooltip as I'd expect. GameTooltip's SetCurrencyToken continues to work as expected. Unfortunately I've not had time to look into this more beyond acknowledging that was a problem. Looks like you use that too.
  Reply With Quote
10-06-22, 11:34 AM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,771
As per Gello's response... 10.0 PTR has OnTooltipSetItem exists but on 10.0 Beta it doesn't in the ItemRef.xml file.
__________________
  Reply With Quote
10-06-22, 11:38 AM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,633
Presumably the PTR will get the Beta code at some stage before launch, but as it's new there maybe more things to come to match the differences between the two for at least a period before full deprecation.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 10-06-22 at 11:41 AM.
  Reply With Quote
10-06-22, 11:45 AM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,771
Yeah, there are definitely things in flux .. Container file also has differences between PTR and Beta. So I have had to withhold any changes there as I can't fully test it yet. The Container changes are kicking up errors with nUI but not pointing to which line in nUI is causing the problem. So could be a regular error rather than an addon error .. or .. similar to the options and editmode changes, they just don't like addons interfering with frames they want to work with :chuckle:
__________________
  Reply With Quote
10-06-22, 11:47 AM   #8
Yocote
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 5
Originally Posted by Gello View Post
I've found OnTooltipSetItem is not being called for GameTooltip as I'd expect. GameTooltip's SetCurrencyToken continues to work as expected. Unfortunately I've not had time to look into this more beyond acknowledging that was a problem. Looks like you use that too.
Looking at Interface/FrameXML/GameTooltip.xml in https://github.com/Gethe/wow-ui-sour...eb0ac4e2343e35 , it seems that <OnTooltipSetItem> indeed was removed from the <Scripts> section of GameTooltip in this latest patch. Now I wonder if that means that the main tooltip no longer can be hooked in any way ...
  Reply With Quote
10-06-22, 11:55 AM   #9
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,633
It means there's more to "unpack" from the latest changes and possibly more changes to come... must be getting close to launch
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
10-06-22, 01:29 PM   #10
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,771
Originally Posted by Fizzlemizz View Post
It means there's more to "unpack" from the latest changes and possibly more changes to come... must be getting close to launch
Somethings happening or something is horribly wrong .. PTR Servers are still down ( I checked Over 20 hours ago ). And the update for Retail is in a loop.

Edit: Well the update finally kicked in just now. But PTR servers are still down.
__________________

Last edited by Xrystal : 10-06-22 at 01:37 PM.
  Reply With Quote
10-09-22, 10:07 AM   #11
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Lua Code:
  1. local function ResetItem2(tooltip)
  2.     print("ResetItem")
  3. end
  4.  
  5. local function SetItem2(tooltip)
  6.     local tooltipData = tooltip:GetTooltipData()
  7.     if(tooltipData and tooltipData.id and tooltipData.type == 0) then -- type -> 0 = item, 1 = spell
  8.         print("SetItem", tooltipData.type, tooltipData.id)
  9.         tooltip:AddLine('Test')
  10.         GameTooltip_CalculatePadding(tooltip)
  11.     end
  12. end
  13.  
  14. hooksecurefunc(GameTooltip, "Show",SetItem2)
  15. hooksecurefunc(GameTooltip, "Hide",ResetItem2)
  16. --GameTooltip:HookScript("OnShow", SetItem2)
  17. --GameTooltip:HookScript("OnHide", ResetItem2)

I'm looking into this, too because of my items addon. I can change the tooltip and add a line. With hooksecure my function is called multiple times a second and the line is added 1-3 times for a tooltip (3 times when I hover over one of the bags in the bagbar, 2 times mostly for items). With HookScript its called only once but the tooltip is changed back after my line shows up for a split second. Not so promising I really hope someone has a good guide how this is meant to work in the future
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
10-09-22, 01:04 PM   #12
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,633
Docs have been updated.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
10-27-22, 03:16 AM   #13
sirpucna
A Fallenroot Satyr
Join Date: Nov 2016
Posts: 29
is the pre patch using a old version of wow compared to the beta?
Retail Pre-Patch: 46313
Current Beta: 46259

Seems many of the old Tooltip handlers are still used whereas the new ones suggested for beta dont work
So just ended up doing this:
Code:
if TooltipDataProcessor then
	TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Unit, TooltipSetUnit)
else
	GameTooltip:HookScript("OnTooltipSetUnit", TooltipSetUnit)
end
  Reply With Quote
11-30-22, 08:54 AM   #14
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 308
Is there still a way to do a pre-hook on what used to be OnTooltipSetItem?

I want to operate on the tooltip of items before any other addons added their lines to it.
Before 10.0.2 I executed this code (a few seconds after login, to make sure that all other addons have already registered):

Lua Code:
  1. local OtherScripts = GameTooltip:GetScript("OnTooltipSetItem")
  2. local function RunOtherScripts(self, ...)
  3.   if OtherScripts then
  4.     return OtherScripts(self, ...)
  5.   else
  6.     return
  7.   end
  8. end
  9.  
  10. GameTooltip:SetScript("OnTooltipSetItem", function(self, ...)
  11.  
  12.   -- Do my stuff with the untouched tooltip.
  13.  
  14.   -- Then let the other addons append their lines.
  15.   return RunOtherScripts(self, ...)
  16. end)


How could the same effect be achieved with the new TooltipDataProcessor?
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
01-25-23, 01:51 AM   #15
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 308
Originally Posted by LudiusMaximus View Post
Is there still a way to do a pre-hook on what used to be OnTooltipSetItem?
I just found out that there is also a `TooltipDataProcessor.AddTooltipPreCall`, which seems to let you do stuff to the tooltip before any other addons have done their modifications.
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
01-25-23, 07:32 PM   #16
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,233
Other addons can also register with that function and there's no guarantee that your code would run first. Nor is there a way to force it without causing taint, which is more of an issue now that the new TooltipDataHandler is capable of handling secure code.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 01-25-23 at 07:36 PM.
  Reply With Quote
01-26-23, 02:21 AM   #17
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 308
That's true. Thanks for pointing it out.
In fact, it seems that the registered functions are executed in the order they have been registered. So it is not possible to make sure you are first by waiting with the registration.


Lua Code:
  1. local startupFrame = CreateFrame("Frame")
  2. startupFrame:RegisterEvent("PLAYER_LOGIN")
  3. startupFrame:SetScript("OnEvent", function(self, event, ...)
  4.  
  5.   TooltipDataProcessor.AddTooltipPreCall(Enum.TooltipDataType.Item, function(self)
  6.     print("Registered first.")
  7.   end)
  8.  
  9.   C_Timer.After(3.0, function()
  10.     TooltipDataProcessor.AddTooltipPreCall(Enum.TooltipDataType.Item, function(self)
  11.       print("Registered after 3 seconds.")
  12.     end)
  13.   end)
  14.  
  15.   C_Timer.After(5.0, function()
  16.     TooltipDataProcessor.AddTooltipPreCall(Enum.TooltipDataType.Item, function(self)
  17.       print("Registered after 5 seconds.")
  18.     end)
  19.   end)
  20.  
  21. end)

Printed result is:
Registered first.
Registered after 3 seconds.
Registered after 5 seconds.
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
01-26-23, 10:01 AM   #18
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,233
Originally Posted by LudiusMaximus View Post
In fact, it seems that the registered functions are executed in the order they have been registered.
Indeed. The functions are registered by table.insert() and iterated with ipairs().
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Tooltip hook stopped working in latest patch?

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