Thread Tools Display Modes
06-08-14, 05:52 PM   #1
TULOA
A Wyrmkin Dreamwalker
 
TULOA's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 50
DropDown Menus

I have been trying to create a wrapper function to make a dropdown list by using a table as the master container. I can get the main level to populate but not the following lists.

I am trying to make it run off the following table layout:

menuList = {text, hasArrow, function, menuList}

it will parse through and use the text and function if hasArrow is false. Otherwise it runs through the text and hasArrow and menuList.

The examples I found otherwise I havent been able to adapt to work. Mainly because I dont fully understand the level building for sublevels.
 
06-08-14, 06:00 PM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Have you consulted this guide?
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
 
06-08-14, 06:07 PM   #3
TULOA
A Wyrmkin Dreamwalker
 
TULOA's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 50
Originally Posted by Torhal View Post
Have you consulted this guide?
Yes cant seem to adapt it to my needs... I dont populate it off a random or set generation like that and I dont pass a list. It needs to allow a table in place of "Games" and run through the table to set all the elements.

I tried to replace the elseif menuList == "Games" and make it instead:
Code:
else
    for a,b in pairs(menuList[2]) do
        info.func = menuList[1]
        info.text = menuList[2][a]
        UIDropDownMenu_AddButton(info, level)
    end
end
The above is a rough cut estimation of what I remember but is basically what I did. All it did was add to the end of the 1st level.
 
06-08-14, 06:18 PM   #4
TULOA
A Wyrmkin Dreamwalker
 
TULOA's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 50
If someone can help out with a more direct function running off a table I would appreciate it. I just had one more idea I am going to try and if it works I will post it back here.

Otherwise I will still be looking.
 
06-08-14, 06:40 PM   #5
TULOA
A Wyrmkin Dreamwalker
 
TULOA's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 50
Originally Posted by TULOA View Post
If someone can help out with a more direct function running off a table I would appreciate it. I just had one more idea I am going to try and if it works I will post it back here.

Otherwise I will still be looking.
Ok I wiggled something up that I can improve off of:

Following Requires: menuList, SubList with texts in menuList as keys.
Code:
	local info = UIDropDownMenu_CreateInfo()
		
		if level == 1 then
			for a,b in pairs(menuList) do
				info.text = b[1]
				info.hasArrow = b[2]
				
				UIDropDownMenu_AddButton(info, level)
			end
		elseif level == 2 then
			
			for a,b in pairs(menuList[UIDROPDOWNMENU_MENU_VALUE][3]) do
				info.text = b
				info.func = OnClick
				
				UIDropDownMenu_AddButton(info, level)
			end
		end
Edit: Fixed to run off one table.

Last edited by TULOA : 06-08-14 at 06:50 PM.
 
06-08-14, 06:57 PM   #6
TULOA
A Wyrmkin Dreamwalker
 
TULOA's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2009
Posts: 50
So my new question becomes...:

How can I make that function infinitely nesting?

Heres the sample table I used in the function above:
Code:
testMenuList = {Greetings = {"Greetings", true, {"hi", "hello", "good day"}}, Farewells = {"Farewells", true, {"bye", "goodbye", "later"}}}
 

WoWInterface » Developer Discussions » Lua/XML Help » DropDown Menus


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off