View Single Post
05-09-23, 10:23 AM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
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:
  1. local mt = {
  2.     AppendScript = function(self, handler, method)
  3.         local func = self:GetScript(handler)
  4.         self:SetScript(handler, function(...)
  5.             func(...)
  6.             method()
  7.         end)
  8.     end,
  9. }
  10.  
  11. local frame = CreateFrame("BUTTON", "MyParty1", UIParent, "BackdropTemplate")
  12.  
  13. setmetatable(frame, { __index = setmetatable(mt, getmetatable(frame)) })
  14.  
  15. frame:SetSize(200, 40)
  16. frame:SetBackdrop({ bgFile = "Interface\\BUTTONS\\WHITE8X8", tile = true, tileSize = 8 })
  17. frame:SetBackdropColor(0, 0, 0)
  18. frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
  19.  
  20. local count = 0
  21. frame:SetScript("OnEnter", function(self) -- Initial SetScript is required so others can be added.
  22.     count = count + 1
  23.     print(count, "First Enter")
  24. end)
  25.  
  26. local function FirstAdded(self)
  27.     print(count, "First Added On Enter!!!")
  28. end
  29. frame:AppendScript("OnEnter", FirstAdded)
  30.  
  31. local function SecondAdded(self)
  32.     print(count, "Second Added On Enter!!!")
  33. end
  34. frame:AppendScript("OnEnter", SecondAdded)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 05-09-23 at 10:27 AM.
  Reply With Quote