Thread Tools Display Modes
Prev Previous Post   Next Post Next
02-14-14, 07:35 PM   #25
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Aanson View Post
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 View Post
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.
__________________
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.

Last edited by Phanx : 02-14-14 at 07:52 PM.
  Reply With Quote
 

WoWInterface » Developer Discussions » General Authoring Discussion » Chat message colours


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