Thread Tools Display Modes
Prev Previous Post   Next Post Next
10-30-20, 11:04 PM   #1
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
HookScript mystery??

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?
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » HookScript mystery??

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