Since
OnTooltipSetItem does no longer exist, we have to use TooltipDataProcessor.AddTooltipPostCall.
I am running into the following problem, when trying to read the tooltip of recipes that are themselves creating items which that teach you something (e.g.
https://www.wowhead.com/item=67308).
With AddTooltipPostCall I only get the tooltip of the usable item which the recipe creates, but not of the recipe itself.
To reproduce, use this code and mouse-hover over the created frame to show the tooltip:
Lua Code:
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, function(self)
local name, link = TooltipUtil.GetDisplayedItem(self)
print(name, link)
-- Read the tootip lines.
local itemId = tonumber(string_match(link, "^.-:(%d+):"))
local tooltipLines = C_TooltipInfo.GetItemByID(itemId).lines
local numLines = 1
while tooltipLines[numLines] do
print(numLines .. ":", tooltipLines[numLines].args[2].stringVal)
numLines = numLines + 1
end
end);
-- To test recipe tooltip:
local testframe1 = CreateFrame("Frame", _, UIParent, BackdropTemplateMixin and "BackdropTemplate")
testframe1:SetBackdrop({ bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/DialogFrame/UI-DialogBox-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 }})
testframe1:SetBackdropColor(0.0, 0.0, 0.0, 1.0)
testframe1:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
testframe1:SetWidth(300)
testframe1:SetHeight(100)
testframe1:SetScript("OnEnter", function()
GameTooltip:SetOwner(testframe1, "ANCHOR_TOPLEFT")
-- Recipe creating a usable item.
GameTooltip:SetHyperlink("item:67308:0:0:0:0:0:0:0")
-- Another recipe for which there is no problem:
-- GameTooltip:SetHyperlink("item:198132:0:0:0:0:0:0:0")
GameTooltip:Show()
end )
Any ideas how to handle this?
When OnTooltipSetItem still existed, we used to get two OnTooltipSetItem when the tooltip was created: one for the recipe and one for the create item.
But now it seems we only get the equivalent of the latter.