Dynamic Button Layouts
Hi all
I have a frame that will contain buttons. I have a number of buttons that will differ based on checkbox selections. Each button is already created, (all in lua), yet they have no default anchor points. I have tried to build a function that should layout the buttons correctly yet I keep getting attempt to call method 'ClearAllPoints' errors This is my very first attempt at such a function and I have tried many different ways all with the same outcomes. Here is my last function; Lua Code:
I have also tried to build the buttons on the fly yet some buttons run a macro whilst others have onclick functions and that also has been punishing. What is the proper way to solve this issue? Also, I have a view to making the frame resizable so the buttons will need to shift at the same time, though this a want to, rather than a need to. |
Lua Code:
Wiithout know what ButtonTable holds my guess is you could use v instead of all the "thisButton" references. |
Sorry, here is my table;
Lua Code:
So the v value is either true or false. Also each button is already created and local, the layout function is only fired on login. |
What is LogoutButton, ExitButton etc.?
Presuambly they relate in some way to how you're creating your buttons but it's all a bit hard to tell with just the code presented. |
Hi Fizzlemizz
You are right, it is really unfair to ask you guys for help without the full code. Here is a link to my code on paste bin |
Possibly something like this so you can store references to your created buttons into ButtonTable
Lua Code:
|
Using the Pastebin code and assuming all your button names are consistant starting with "NewbDevBoxButtonFrame" and prefixed with the name in ButtonTable ie.
Code:
local xxx = CreateFrame("Button", "NewbDevBoxButtonFrameLogoutButton", NewbDevBoxButtonFrame, "SecureActionButtonTemplate, GameMenuButtonTemplate") Lua Code:
Edit: typos. |
Hi Fizzlemizz
Thanks for that, using _G[] does get rid of the errors yet it does not give me the desired button layout. With every button selected I get just 2 visible, (btns 6 and 10), and neither is anchored to the frame. I have commented out the original buttons setpoints to test. Here is my table of variables and the updated function; Lua Code:
I have uploaded both my lua and toc files to pasbin |
It looks like you're wanting something like the following to create a set of columns/rows:
Lua Code:
This creates a column of 3 starting with the Reload button and then starts the next column to the right of the last button designated the "top button" of the last column. Because the table you're cycling through (NewbDevBoxDisplayButtonTable) has string keys, they aren't sorted so you can't guarantee the order the buttons will be in. |
Hi Fizzlemizz
Wow, I cannot believe how economical your code is, not only does it work perfectly it is less than a 3rd of all the code and the variable list I had built. Also, I have changed my button list so each button is assigned to a number to maintain the button order. Thank you so much for your help, it is truly appreciated. :D |
All times are GMT -6. The time now is 06:48 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI