View Single Post
11-23-14, 11:27 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Oh, and another thing. Unless you ABSOLUTELY need your button to have a global name, accessible from outside of your addon, then don't bother giving it a global name. You can just do:
Lua Code:
  1. local frame = CreateFrame("Button", nil, UIParent)

If you DO want it to have a global name, then use the local you are assigning your button to as your reference in the Lua code. Locals are faster than global lookups.
Lua Code:
  1. frame:RegisterForClicks("AnyUp")
  2. frame:SetScript("OnClick", function(self, button, ...)
  3.     if (button == "RightButton") then
  4.         if frame:IsShown() then
  5.             frame:Hide()
  6.         else
  7.             frame:Show()
  8.         end
  9.     end
  10. end)

/edit: heh... just noticed that you had the :SetHidden() call backwards anyway
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote