AggrorJorn Posted July 25, 2010 Share Posted July 25, 2010 The titel is perhaps a little overdue to the actual problem. Here is the situation. I am working on my Gui and it is time for me to create a dropdown button. (you might have notice the status update ) I want to create this Gui so that it is really easy accesible and easy to understand for everyone. Basicly said: a Dropdown button actually exists out of multiple normal buttons (with normal, hover and mousedown mode). What I hope to achieve is something like the code beneath. dropdown1 = LuaGui.CreateDropDown(2) -- number of rows is filled in as a parameter dropdown1:SetImages("abstract::normal.dds","abstract::hover.dds") dropdown1.row1:SetImages("abstract::normal.dds","abstract::hover.dds") dropdown1.row2:SetImages("abstract::normal.dds","abstract::hover.dds") As you can see, row1 and row2 members of the dropdown button that is created. In the Gui code itself I have this: function LuaGui.CreateDropDown(rows) local o = {} setmetatable(o, LuaGui) --rows o.row = {} for n=1,rows do o.row[n] = LuaGui.CreateButton()--Create a basic button for every row. end return o Any suggestions? Quote Link to comment Share on other sites More sharing options...
Rick Posted July 26, 2010 Share Posted July 26, 2010 Does that work? I assume you maybe meant .rows[0].SetImages()? instead of row1, or maybe that's a table feature I'm not aware of. Either way are you asking for other ideas than the idea you have there? 1 Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 26, 2010 Share Posted July 26, 2010 i think rick is right... ,row[1] is not the same variable as row1... perhaps thats just a mistake on your psuedocode tho... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 26, 2010 Author Share Posted July 26, 2010 I guess I forgot to mention the most important part to make this topic in the first place: it doesn't work.... But you helped me out again. It has to be dropdown1.row[1] instead if dropdown1.row1. I figured that the Gui code would place the number just behind the row. Which, after reading this line, doesn't make much sense. The actual problem is solved but suggestions, comments, constructive critism are all welcome. It might put me to some ideas. Thanks for the help Rick +1 Quote Link to comment Share on other sites More sharing options...
Rick Posted July 26, 2010 Share Posted July 26, 2010 It's not a bad design, but I don't think it's flexible enough. If someone wants to add rows on the fly this doesn't seem to account for that. I would drop the parameter which you seem to be using to tell how many are in the table. Use something like the below if you need to loop through the table: for index,value in ipairs(t) do print(index,value) end Then maybe make an AddButton() method that will add a button to the next index in the array (you can keep this count in a variable to the class if you like, although I would make they keys in the table a name of the button so people could retrieve the button from the table by name later if they so wish. So AddButton() would take a parameter which would be the string name to call the button in the table). Quote Link to comment Share on other sites More sharing options...
cocopino Posted July 26, 2010 Share Posted July 26, 2010 Just to frustrate you a little bit further Aggror: To have a really nice dropdown, it also needs a container with a background image and a slider (another image) so you can scroll through items. Quote desktop: Quad core Q6600 + 4GB + ATI HD4890 + XP laptop: Dual core T6400 + 4 GB + NVidia 9600M GT + Vista 32 Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 29, 2010 Author Share Posted July 29, 2010 ey guys! Yes there are many flaws to the gui design. Not just this dropdown button but the Gui in general. But I am just seeing how far I can get with squirming around and trying stuff out. I have the principle of OOP in my head with this Gui, but it isn't really used yet. As for the: for index,value in ipairs(t) do print(index,value) end I'll give it a go! @ cocopino. You are right, that should be added as well. But then I should let people have the ability to create panels as well. I am afraid it would take me little to much time to find this out. I want to focus merely on the things that I can do (and understand). Still, thanks for the reminder. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.