Originally Posted by Lombra
|
Originally Posted by Aanson
But that points to CF_MEH which is where 'self' is coming from. I know that MessageEventHandler is passed with chat frame as it's 1st arg. Filters don't. If you check out ChatFrame_AddMessageEventFilter (event, filter) line 3193 of ChatFrame.lua, you'll see what I'm talking about.
|
Look again. The specific line of code Lombra linked clearly shows that
self -- which in that scope is a reference to the chat frame handling the event -- is the first argument passed to every chat filter function.
The
lines you mentioned handle
adding new filter functions -- that part of the code has nothing to do with calling filter functions.
Originally Posted by Aanson
That way I have a guarantee that the message will actually be displayed. It should be reliable because self.lastEvent will always be obtained immediately before AddMessage gets called.
|
That's not reliable at all. The default UI calls
AddMessage from inside its OnEvent script, and
HookScript is the equivalent of
hooksecurefunc -- it runs your script
after the original, so your event handler hook will run
after the default UI has already called
AddMessage, and your
AddMessage hook will be seeing the
previous event. In many cases (eg. Trade chat in a city) this will be the same event, but in many other cases it will not be.