Can anybody explain the logic of this behaviour??
I am hooking OnTooltipSetItem and OnTooltipCleared of GameTooltip at two different times: when loading the addon and again with a 1 second delay:
Code:
GameTooltip:HookScript("OnTooltipSetItem", function() print("INIT >> SetItem") end)
GameTooltip:HookScript("OnTooltipCleared", function() print("INIT << Cleared") end)
C_Timer.After(1, function()
GameTooltip:HookScript("OnTooltipSetItem", function() print("WAIT >> SetItem") end)
GameTooltip:HookScript("OnTooltipCleared", function() print("WAIT << Cleared") end)
end)
Then, when the mouse cursor enters an item icon, I get the following:
Code:
INIT >> SetItem
INIT << Cleared
WAIT << Cleared
WAIT >> SetItem
INIT << Cleared
WAIT << Cleared
As the tooltip is permantenyl refreshed, this pattern of lines is actually repeated.
But what I don't understand is why the "INIT" prints get executed first for BOTH SetItem and Cleared, and only then the "WAIT" prints get executed but in the opposite order (first Cleared then SetItem)?
I would have expected that INIT and WAIT are always executed one after the other. So what does it matter if I set the hook when loading the addon or with a delay?