View Single Post
07-09-13, 03:00 AM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
No, there was a mistake in my code (I hadn't tested it in-game when I posted it) and the buttons weren't actually getting stored in the table, so anchoring Button2 failed, causing it to be invisible. I fixed it, so if you copy the code again it should work.

The part at the end is not real code, though, so it should remain commented out; it's just to show you what ends up in the table, so you can do stuff with it later. For example, if later you decided you wanted all the buttons to be 800px wide instead of 200px wide:

Code:
for i = 1, #buttons do
   buttons[i]:SetWidth(800)
end
On a side note, you will likely see the above type of loop written using ipairs in many places:

Code:
for i, button in ipairs(buttons) do
   button:SetWidth(800)
end
While this may seem like a more straightforward way to traverse an indexed table, it's actually a lot slower, and offers no advantages whatsoever over the ipairs-free version, so you should not use it.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote