WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   3rd dropdown tier (https://www.wowinterface.com/forums/showthread.php?t=49256)

Tactica 05-04-14 04:08 PM

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.

Lombra 05-04-14 05:35 PM

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.

Tactica 05-04-14 05:52 PM

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!

Lombra 05-05-14 04:22 AM

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.


All times are GMT -6. The time now is 05:37 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI