View Single Post
09/02/15, 09:32 AM   #15
ZOS_ChipHilseberg
ZOS Staff!
Premium Member
Yes this person is from ZeniMax!
Join Date: Oct 2014
Posts: 551
1. Best:
Lua Code:
  1. <Texture name="Sample">
  2.     <OnMouseEnter>
  3.         --Code
  4.     </OnMouseEnter>
  5. </Texture>

2. Also Good:
Lua Code:
  1. --This is run once when the addon loads
  2. function InitializeAddon(texture)
  3.     texture:SetHandler("OnMouseEnter", function()
  4.         --Code
  5.     end)
  6. end

3. Bad:
Lua Code:
  1. --This is run often
  2. function SetupTexture(texture, width, height)
  3.     texture:SetHandler("OnMouseEnter", function()
  4.         --Code
  5.     end)
  6.     texture:SetDimensions(width, height)
  7. end

Instead of 3, which keeps setting the same handler code over and over again use 1 or 2 to only do it once.
  Reply With Quote