View Single Post
09-08-10, 09:53 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Tiok View Post
With "event" gone, how do we tell which event occurred in the XML-defined OnEvent handler?

how do you get access to event arguments inside the XML-defined OnEvent handler, so you can pass them through?
As with self, the event and any arguments are passed to your OnEvent handler. These are identical:

Code:
local myFrame = CreateFrame("Frame", "MyFrame")
myFrame:SetScript("OnEvent", function(self, event, ...)
    -- self is a reference to the frame
    -- event is a string indicating which event is being handled
    -- ... is a vararg containing any and all arguments passed with the event
end)
Code:
<Frame name="MyFrame">
    <OnEvent>
        -- self is a reference to the frame
        -- event is a string indicating which event is being handled
        -- ... is a vararg containing any and all arguments passed with the event
    </OnEvent>
</Frame>
As someone else already pointed out, you get the individual arguments like this:
Code:
local arg1, arg2, arg3 = ...