Quantcast
WoWInterface - View Single Post - Tracking currency updates
View Single Post
02-19-18, 09:49 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Layback_ View Post
So, do "TokenFrame_Update" function and "CURRENCY_DISPLAY_UPDATE" event get called simultaneously?
That question doesn't make any sense. Events don't get called. Events fire (that is to say, they are emitted by the game, and that action occurs in the underlying C code, not in the Lua code that creates and controls the UI) and UI code can listen for events and call functions in response to them.

If you're asking whether the UI calls TokenFrame_Update in response to CURRENCY_DISPLAY_UPDATE, the answer now appears to be yes, which means I could probably use an event handler instead of hooking functions in my addon if I wanted to bother changing it. Like I said, I don't recall why I used that solution when I wrote my addon 8 years ago.

That also means that the answer to your original question is probably that the best solution here is to listen for the CURRENCY_DISPLAY_UPDATE event. If you try that, and are seeing currency numbers changing without the event firing, report back with a description of the circumstances.

Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
  3. f:SetScript("OnEvent", function(f, e, ...)
  4.    print(e, ...)
  5. end)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Donít message me about addon bugs or programming questions.
  Reply With Quote