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:
GameTooltip:HookScript("OnTooltipSetItem",function(self)
local name,itemlink=self:GetItem();
-- Do stuff
end);
Retail:
Lua Code:
local function OnTooltipSetItem(self,itemlink)
-- Do Stuff
end
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item,function(self)
local itemlink; do
local tooltip_info=self:GetProcessingTooltipInfo();
local tooltip_data=tooltip_info and tooltip_info.tooltipData;
itemlink=tooltip_data and (tooltip_data.guid and C_Item.GetItemLinkByGUID(tooltip_data.guid) or tooltip_data.hyperlink);
end
if itemlink then OnTooltipSetItem(self,itemlink); end
end);
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Macro,function(self)
local itemlink; do
local tooltip_info=self:GetProcessingTooltipInfo();
if tooltip_info and tooltip_info.getterName=="GetAction" then
itemlink=select(2,GetMacroItem(select(2,GetActionInfo(tooltip_info.getterArgs[1]))));
end
end
if itemlink then OnTooltipSetItem(self,itemlink); end
end);
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Toy,function(self)
local itemlink; do
local tooltip_info=self:GetProcessingTooltipInfo();
local tooltip_data=tooltip_info and tooltip_info.tooltipData;
itemlink=tooltip_data and C_ToyBox.GetToyLink(tooltip_data.id);
end
if itemlink then OnTooltipSetItem(self,itemlink); end
end);
Retail requires more processing of a few different TooltipData structures, all that will produce an item tooltip.