Originally Posted by Yksrep
I think I understand what you mean, Would this be a correction for that
Code:
Battle_Pet_Trainer_Stormwind = CreateFrame("Button", "Battle_Pet_Trainer_Stormwind",content,"UIPanelButtonTemplate") -- Row 1 Column 1
Battle_Pet_Trainer_Stormwind:SetText("Battle Pet Trainer")
Battle_Pet_Trainer_Stormwind:SetPoint("TOPLEFT",0,0)
Battle_Pet_Trainer_Stormwind:SetWidth(120)
Battle_Pet_Trainer_Stormwind:SetHeight(50)
|
The first line has a redundancy in it. Since
CreateFrame() already sets the global, you don't need to set it again with the return from the function, which is the same frame. I marked the unnecessary part of the line that should be removed in red.
However, I was suggesting you phase out the use of the globals and use the local you were creating instead. This would be as Phanx suggested.
Originally Posted by Phanx
That's a better global name, but it is still too generic -- it should include your addon's name so it is immediately obvious which addon created it -- and you are still using a slow global reference instead of a faster local one.
Code:
local button = CreateFrame("Button", "MyAddonStormwindBattlePetTrainer", content, "UIPanelButtonTemplate") -- Row 1 Column 1
button:SetText("Battle Pet Trainer")
button:SetPoint("TOPLEFT",0,0)
button:SetWidth(120)
button:SetHeight(50)
|