Thread Tools Display Modes
05-17-24, 10:55 AM   #1
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 134
Tooltip when hovering over an item.

Lua Code:
  1. local addonName, addon = ...
  2. -- Define localization table for German language
  3. local L = {
  4.     [210714] = {
  5.         ["name"] = "Abgesplitterter tödlicher Saphir", -- Translate item name
  6.     },
  7. }
  8.  
  9. -- Hooking into the default GameTooltip to add our custom text
  10. local function AddTooltipInfo(tooltip)
  11.     local _, itemLink = tooltip:GetItem()
  12.     if itemLink then
  13.         local itemId = tonumber(itemLink:match("item:(%d+)"))
  14.         if itemId then
  15.             -- Check if the item ID is in our localization table
  16.             local localizedItem = L[itemId]
  17.             if localizedItem then
  18.                 tooltip:AddLine(localizedItem["name"])
  19.             end
  20.         end
  21.     end
  22.     tooltip:Show()
  23. end
  24.  
  25. -- Hooking the GameTooltip's SetHyperlink method to update our tooltip
  26. hooksecurefunc(GameTooltip, "SetHyperlink", AddTooltipInfo)

Hi all. I need your help again.

Description of the problem: There is an item in the bag "Chipped Deadly Sapphire" (ID 210714). It is necessary that when you hover the mouse over it or on the object itself, an inscription appears. Or the inscription appeared in the tooltip above the item.

As it is now: The tooltip appears only if the item is “Linked” into the chat.
  Reply With Quote
05-17-24, 10:16 PM   #2
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 134
I tried all the options. But I still couldn’t solve this problem myself.

The item in the bag does NOT have a hint.


If you send a chat message with an item, there is a hint.


How to make sure that the item in the bag also has a hint?
  Reply With Quote
05-18-24, 04:14 AM   #3
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,974
It looks like you already have an addon installed that adds to the tooltip. Maybe how that works is interfering with what you are trying to do. Try without any other addons and just the one you are working on and see how it works then.

I was having this problem with my mageports addon, but my rewrite has removed the need for those changes.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
05-18-24, 05:17 AM   #4
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 134
Originally Posted by Xrystal View Post
It looks like you already have an addon installed that adds to the tooltip. Maybe how that works is interfering with what you are trying to do. Try without any other addons and just the one you are working on and see how it works then.

I was having this problem with my mageports addon, but my rewrite has removed the need for those changes.
I disabled all addons, but the result is the same. I don’t know what to do anymore =(

Retail requires more processing of a few different TooltipData structures, all that will produce an item tooltip.
Thanks it worked.

Last edited by Hubb777 : 05-18-24 at 05:45 AM.
  Reply With Quote
05-18-24, 05:02 AM   #5
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,336
There are many functions that call up the tooltip to show an item. Too many to make it feasible to hook each one individually. Instead, there are scripts/callbacks that fire depending on whether you're running the Classic or Retail client.



Classic:
Lua Code:
  1. GameTooltip:HookScript("OnTooltipSetItem",function(self)
  2.     local name,itemlink=self:GetItem();
  3.  
  4. --  Do stuff
  5. end);



Retail:
Lua Code:
  1. local function OnTooltipSetItem(self,itemlink)
  2. --  Do Stuff
  3. end
  4.  
  5. TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item,function(self)
  6.     local itemlink; do
  7.         local tooltip_info=self:GetProcessingTooltipInfo();
  8.         local tooltip_data=tooltip_info and tooltip_info.tooltipData;
  9.         itemlink=tooltip_data and (tooltip_data.guid and C_Item.GetItemLinkByGUID(tooltip_data.guid) or tooltip_data.hyperlink);
  10.     end
  11.  
  12.     if itemlink then OnTooltipSetItem(self,itemlink); end
  13. end);
  14.  
  15. TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Macro,function(self)
  16.     local itemlink; do
  17.         local tooltip_info=self:GetProcessingTooltipInfo();
  18.         if tooltip_info and tooltip_info.getterName=="GetAction" then
  19.             itemlink=select(2,GetMacroItem(select(2,GetActionInfo(tooltip_info.getterArgs[1]))));
  20.         end
  21.     end
  22.  
  23.     if itemlink then OnTooltipSetItem(self,itemlink); end
  24. end);
  25.  
  26. TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Toy,function(self)
  27.     local itemlink; do
  28.         local tooltip_info=self:GetProcessingTooltipInfo();
  29.         local tooltip_data=tooltip_info and tooltip_info.tooltipData;
  30.         itemlink=tooltip_data and C_ToyBox.GetToyLink(tooltip_data.id);
  31.     end
  32.  
  33.     if itemlink then OnTooltipSetItem(self,itemlink); end
  34. end);



Retail requires more processing of a few different TooltipData structures, all that will produce an item tooltip.
__________________
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 » AddOns, Compilations, Macros » AddOn Help/Support » Tooltip when hovering over an item.

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