THIS ADDON IS OUTDATED! IT HAS BEEN ABANDONED! I DON'T PLAN TO UPDATE IT!
A library to create simple interactive dropdrown menus.
Note: This is for developers only!
This is my custom library and I'm uploading it so folks could use it. No, it's not perfect but it does the job. No one is forcing you to use it. I needed a library that could do dropdown menus easily.
I documented the library to make it easier for developers to implement.
If you feel you would like to contribute or make modifictions to this library. Please feel free to visit my GitHub. Also, if you like you can send me a PM here so I will add you as a team member.
You can view Alpha Builds at my Github tracker.
This library supports the following menu items:- Headers
- Lists -> Lists -> Lists
- Toggles (checkmarked items)
- Color Selector
- Multiple DB outputs (optional parameters available)
- Extended menu system
Code:
local dd1 = LibStub('LibXMenu-1.0'):New("DropDownName", database)
dd1.db.color1val = { r = 0, g = 0, b = 0, a = 1, }
dd1.initialize = function(self, lvl)
if lvl == 1 then
self:AddTitle(lvl, "My DropDown")
self:AddList(lvl, "Font Size", "fontsize")
self:AddList(lvl, "Advance List", "advancelist")
self:AddColor(lvl, "Color 1", "color1val")
self:AddToggle(lvl, "Switch", "switch")
self:AddToggle(lvl, "Switch2", "switch2", otherdb, "otherdboption2")
elseif lvl and lvl > 1 then
local sub = UIDROPDOWNMENU_MENU_VALUE
if sub == "fontsize" then
--loop selection add
for i = 5, 12, 1 do
self:AddSelect(lvl, i, i, "fontsize", nil)
end
elseif sub == "advancelist" then
--several different ways of adding selects
self:AddSelect(lvl, i, i, db, "dboption1", nil)
self:AddSelect(lvl, i, i, "dboption2", nil)
end
end
end
dd1.doUpdate = function()
--fired after every menu selection click
doDisplayUpdates();
end
ToggleDropDownMenu(1, nil, dd1, "cursor")
Another example of the library in use. This is how I implemented it in my addon.
Code:
local dd1 = LibStub('LibXMenu-1.0'):New("Xan_DropDown", Xan_DB)
dd1.initialize = function(self, lvl)
if lvl == 1 then
self:AddTitle(lvl, "XanMod")
self:AddList(lvl, L["Combat Session"], "combatsession")
self:AddList(lvl, L["Data Type"], "datatype")
self:AddList(lvl, L["Background Opacity"], "bgOpacity")
self:AddCloseButton(lvl, L["Close"])
elseif lvl and lvl > 1 then
local sub = UIDROPDOWNMENU_MENU_VALUE
if sub == "combatsession" then
self:AddSelect(lvl, L["Previous"], "previous", "cSession")
self:AddSelect(lvl, L["Current"], "current", "cSession")
self:AddSelect(lvl, L["Total"], "total", "cSession")
elseif sub == "datatype" then
local cCount = 0
for k, v in pairsByKeys(d_modes) do
cCount = cCount + 1
self:AddSelect(lvl, L[v.name], v.name, "viewStyle", nil, nil, cCount)
end
elseif sub == "bgOpacity" then
for i = 0, 1, 0.1 do
self:AddSelect(lvl, i, i, "bgOpacity")
end
end
end
end
dd1.doUpdate = function(bOpt)
if bOpt == 1 or bOpt == 2 then
--a button that was assigned a bOpt was pressed with numbers 1 and 2
doSomethingElse();
end
updateDisplay();
end
ToggleDropDownMenu(1, nil, dd1, "cursor", 0, 0)