Thread Tools Display Modes
05-04-14, 04:08 PM   #1
Tactica
Not Amused
 
Tactica's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 96
3rd dropdown tier

I admit I know nothing about dropdown functions. Would like to add a third tier to this code for All, Lookalike, and Recolor as a "check/tick" setting.
Code:
function module.Dropdown(module,tier)
	local info;
	if tier == 1 then
		info = UIDropDownMenu_CreateInfo();
		info.text = module.label;
		info.value = module;
		info.colorCode = "\124cFF00FF00";
		info.hasArrow = true;
		info.keepShownOnClick = true;
		info.notCheckable = true;
		UIDropDownMenu_AddButton(info,tier);
	elseif tier == 2 then
		for k,v in ipairs(armor) do
			info = UIDropDownMenu_CreateInfo();
			info.text = v;
			-- info.value = v; -- value equals text if omitted!
			info.notCheckable = true;
			info.func = DropdownTier2;
			info.arg1 = module;
			UIDropDownMenu_AddButton(info,tier);
		end
	end
end
Not sure if you need more code to know whats going on...thanks in advance.
  Reply With Quote
05-04-14, 05:35 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
I can see that this is based on some part of MogIt, so I can help you.. mostly. (I didn't write these things personally) Well there are only a few details that are specific to MogIt, for that matter.

Anyway, what you need to do is add another clause for when "tier == 3", where you create the items of the new submenu. There is some special variable you can use to see which menu was opened, but I can't remember right now. Not sure how you meant it should look, though.

You also need to set .hasArrow = true on the level 2 items that should open the level 3 menu, and create those items if not using existing ones.

If this doesn't help you need to try to describe better what you want to do, so we can describe better how to do it.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
05-04-14, 05:52 PM   #3
Tactica
Not Amused
 
Tactica's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 96
Here is a pic of what I have so far:


Would like the arrow to allow me to select/tick/check if I want to view "All" or just "Recolor" or just "Lookalike" from the module data.
Code:
local function DropdownTier2(self)
	module.active = self.value
	mog:SetModule(self.arg1,"Sets - "..self.value);
	CloseDropDownMenus();
end

local function DropdownTier3(self)
	module.active = self.value
	mog:SetModule(self.arg1,"Sub Sets - "..self.value);
	CloseDropDownMenus();
end

function module.Dropdown(module,tier)
	local info;
	if tier == 1 then
		info = UIDropDownMenu_CreateInfo();
		info.text = module.label;
		info.value = module;
		info.colorCode = "\124cFF00FF00";
		info.hasArrow = true;
		info.keepShownOnClick = true;
		info.notCheckable = true;
		UIDropDownMenu_AddButton(info,tier);
	elseif tier == 2 then
		for k,v in ipairs(armor) do
			info = UIDropDownMenu_CreateInfo();
			info.text = v;
			-- info.value = v; -- value equals text if omitted!
			info.notCheckable = true;
			info.hasArrow = true;
			info.func = DropdownTier2;
			info.arg1 = module;
			UIDropDownMenu_AddButton(info,tier);
	elseif tier == 3 then
		for k,v in ipairs(armor) do
			info = UIDropDownMenu_CreateInfo();
			info.text = v;
			-- info.value = v; -- value equals text if omitted!
			info.notCheckable = false;
			info.func = DropdownTier3;
			info.arg1 = module; --Sets?
			UIDropDownMenu_AddButton(info,tier);
		end
	end
end
Project can be found here for reference!
  Reply With Quote
05-05-14, 04:22 AM   #4
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Alright, then you just need to create the level 3 items.

Something like this:
Code:
	elseif tier == 3 then
		local info = UIDropDownMenu_CreateInfo();
		info.text = "All";
		info.func = DropdownTier3;
		info.arg1 = module; --Sets?
		UIDropDownMenu_AddButton(info,tier);
		
		local info = UIDropDownMenu_CreateInfo();
		info.text = "Recolor";
		info.func = DropdownTier3;
		info.arg1 = module; --Sets?
		UIDropDownMenu_AddButton(info,tier);
		
		local info = UIDropDownMenu_CreateInfo();
		info.text = "Lookalike";
		info.func = DropdownTier3;
		info.arg1 = module; --Sets?
		UIDropDownMenu_AddButton(info,tier);
	end
Either use the same function for all three items, and differentiate using the .arg1 field (you can assign any value you want to it), or use three different functions and don't bother with arg1. Former should be "better" but won't really matter.
__________________
Grab your sword and fight the Horde!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » 3rd dropdown tier

Thread Tools
Display Modes

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