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,813
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,853
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,813
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,853
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,813
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,853
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,813
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: 320
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: 320
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,304
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: 320
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,304
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
05-29-23, 05:00 AM   #19
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,853
I have a similar problem in nUI now that I have reinstated its action bars back to service.

nUI adds Keybinding info to the action button tooltip which of course no longer displays permanently due to the tooltip changes I presume.

Now, looking at your findings I tried to do something similar but it has gone belly up.

In PLAYER_LOGIN I have the following block of code - amongst other code
Lua Code:
  1. for i in pairs( nUI_ButtonBars.Bars ) do
  2.     local bar = nUI_ButtonBars.Bars[i];
  3.     for row in pairs( bar.Buttons ) do
  4.         for col in pairs( bar.Buttons[row] ) do
  5.             local button      = bar.Buttons[row][col];
  6.             local key1, key2  = GetBindingKey( "CLICK "..button:GetName()..":LeftButton" );
  7.  
  8.             TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Spell, function(self)
  9.                 if key1 then GameTooltip:AddLine( nUI_L["Key Binding"].." 1: |cFF00FFFF"..GetBindingText( key1, "KEY_" ).."|r", 1, 1, 1 ); end
  10.                 if key2 then GameTooltip:AddLine( nUI_L["Key Binding"].." 2: |cFF00FFFF"..GetBindingText( key2, "KEY_" ).."|r", 1, 1, 1 ); end                                  
  11.                 if not key1 and not key2 then GameTooltip:AddLine( nUI_L["No key bindings found"], 1, 1, 1 ); end
  12.                  GameTooltip:AddLine( nUI_L["<ctrl-alt-right click> to change bindings"], 0, 1, 1 );                                        
  13.             end)
  14.  
  15.             button:SetScript( "OnEnter", function()
  16.                 if nUI_Options.combat_tooltips or not InCombatLockdown() then
  17.                     button:SetTooltip()
  18.                     -- Old Code used to be here
  19.                     GameTooltip:Show();
  20.                 end
  21.             end );
  22.         end
  23.     end
  24. end
All but the TooltipDataProcessor open and close lines were already in the code, but initially inside the OnEnterScript.

It worked fine before Dragonflight but now inside OnEnter it briefly shows but then disappears, and outside OnEnter it shows a ton of lines running down the screen. Instead of the 1-4 I am expecting per button.

Anyone have any ideas on how I would get it working like before ?

Thanks in advance.


edit:
I also tried creating my own tooltip as follows:
local tooltip = CreateFrame("GameTooltip",nil,button,"GameTooltipTemplate")
And using this instead of GameTooltip but no difference.
__________________

Last edited by Xrystal : 05-29-23 at 05:19 AM.
  Reply With Quote
05-29-23, 06:46 AM   #20
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,304
The problem with registering with TooltipDataProcessor.AddTooltipPostCall() is it's a global register. This means it'll call the function every time anything wishes to display a spell's tooltip. Not just the individual button you're working with.

For example, someone mouseovers a spell in their spellbook and every instance of that function for every button you've created will run sequentially for that single tooltip.



I wouldn't suggest this approach as it would impact performance if everyone would start doing it this way, but here's an attempt to fix your code example.
Lua Code:
  1. local nUI_ButtonCache = {};
  2.  
  3. TooltipDataProcessor.AddTooltipPostCall(TooltipDataProcessor.AllTypes, function(self)
  4.     local owner = self:GetOwner();
  5.     if nUI_ButtonCache[owner] then
  6.         local key1, key2 = GetBindingKey(("CLICK %s:LeftButton"):format( owner:GetName() ));
  7.         if key1 then self:AddLine(("%s 1: |cFF00FFFF%s|r"):format( nUI_L["Key Binding"], GetBindingText( key1, "KEY_" )), 1, 1, 1 ); end
  8.         if key2 then self:AddLine(("%s 1: |cFF00FFFF%s|r"):format( nUI_L["Key Binding"], GetBindingText( key2, "KEY_" )), 1, 1, 1 ); end
  9.         if not (key1 or key2) then self:AddLine( nUI_L["No key bindings found"], 1, 1, 1 ); end
  10.         self:AddLine( nUI_L["<ctrl-alt-right click> to change bindings"], 0, 1, 1 );
  11.     end
  12. end);
  13.  
  14. for _, bar in pairs( nUI_ButtonBars.Bars ) do
  15.     for _, row in pairs( bar.Buttons ) do
  16.         for _, button in pairs( row ) do
  17.             nUI_ButtonCache[button] = true;
  18.             button:SetScript( "OnEnter", function()
  19.                 if nUI_Options.combat_tooltips or not InCombatLockdown() then
  20.                     button:SetTooltip()
  21.                     -- Old Code used to be here
  22.                     GameTooltip:Show();
  23.                 end
  24.             end);
  25.         end
  26.     end
  27. end

As noted earlier, TooltipDataProcessor.AddTooltipPostCall() is a global register, so I reduced its handler to a single function. I registered it with the TooltipDataProcessor.AllTypes enum, which is a special flag that tells the processor to call the handler for every tooltip type. The handler is called with the tooltip being processed and its associated raw data table. We can query its owner with :GetOwner() and check if it's one of our buttons. If it is, we can proceed with posting its keybind info.
__________________
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 : 05-29-23 at 07:34 AM.
  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