If you wanted to do it like that (needed to append multiple scripts and not use HookScript) an example would look something like:
Lua Code:
local mt = {
AppendScript = function(self, handler, method)
local func = self:GetScript(handler)
self:SetScript(handler, function(...)
func(...)
method()
end)
end,
}
local frame = CreateFrame("BUTTON", "MyParty1", UIParent, "BackdropTemplate")
setmetatable(frame, { __index = setmetatable(mt, getmetatable(frame)) })
frame:SetSize(200, 40)
frame:SetBackdrop({ bgFile = "Interface\\BUTTONS\\WHITE8X8", tile = true, tileSize = 8 })
frame:SetBackdropColor(0, 0, 0)
frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
local count = 0
frame:SetScript("OnEnter", function(self) -- Initial SetScript is required so others can be added.
count = count + 1
print(count, "First Enter")
end)
local function FirstAdded(self)
print(count, "First Added On Enter!!!")
end
frame:AppendScript("OnEnter", FirstAdded)
local function SecondAdded(self)
print(count, "Second Added On Enter!!!")
end
frame:AppendScript("OnEnter", SecondAdded)