-
Notifications
You must be signed in to change notification settings - Fork 0
Examples
sfmict edited this page Mar 8, 2024
·
15 revisions
local lsfdd = LibStub("LibSFDropDown-1.5")
local button = lsfdd:CreateButton(parentFrame)
button:SetPoint("TOPLEFT")
button:ddSetSelectedValue(1)
local function selectFunction(menuButton)
button:ddSetSelectedValue(menuButton.value)
-- some code
end
button:ddInitialize(function(self, level)
local info = {}
for i = 1, 10 do
info.text = "Text"..i
info.value = i
info.func = selectFunction
self:ddAddButton(info, level)
end
end)local lsfdd = LibStub("LibSFDropDown-1.5")
local button = lsfdd:CreateStretchButton(parentFrame, 120, 22)
button:SetText("Some text")
button:SetPoint("TOPLEFT")
local function selectFunction(menuButton, arg1, arg2, checked)
print(menuButton.value, arg1, arg2, checked)
-- some code
end
button:ddSetInitFunc(function(self, level)
local info = {}
info.notCheckable = true
info.isTitle = true
info.justifyH = "CENTER"
info.text = "TITLE"
self:ddAddButton(info, level)
self:ddAddSeparator(level)
self:ddAddSpace(level)
info.justifyH = nil
info.notCheckable = nil
info.isTitle = nil
info.isNotRadio = true
info.keepShownOnClick = true
for i = 1, 10 do
info.text = "Text"..i
info.value = "value"..i
info.arg1 = "arg1"..i
info.arg2 = "arg2"..i
info.checked = i % 2 == 0
info.func = selectFunction
self:ddAddButton(info, level)
end
end)local lsfdd = LibStub("LibSFDropDown-1.5")
local button = CreateFrame("BUTTON", nil, parentFrame, "UIMenuButtonStretchTemplate")
button:SetSize(120, 22)
button:SetText("Some text")
button:SetPoint("TOPLEFT")
lsfdd:SetMixin(button)
button:ddSetDisplayMode("menu")
button:ddHideWhenButtonHidden()
button:ddSetNoGlobalMouseEvent(true)
local list = {}
for i = 1, 5 do
local t = {
name = "text"..i,
list = {},
}
for j = 1, 10 do
tinsert(t.list, {
name = "name "..i.." "..j,
value = j,
})
end
tinsert(list, t)
end
button:SetScript("OnClick", function(self)
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
self:ddToggle(1, list, self, 102, 17)
end)
local function selectFunction(menuButton)
print(menuButton.value)
-- some code
end
button:ddSetInitFunc(function(self, level, value)
local info = {}
info.notCheckable = true
for _, v in ipairs(value) do
info.text = v.name
if v.list then
info.keepShownOnClick = true
info.hasArrow = true
info.value = v.list
else
info.value = v.value
info.func = selectFunction
end
self:ddAddButton(info, level)
end
end)local lsfdd = LibStub("LibSFDropDown-1.5")
local button = lsfdd:CreateButton(parentFrame)
button:SetPoint("TOPLEFT")
button:ddSetSelectedValue(1)
local function selectFunction(menuButton)
button:ddSetSelectedValue(menuButton.value)
-- some code
end
button:ddInitialize(function(self, level)
local info = {}
info.list = {}
for i = 1, 30 do
local subInfo = {}
subInfo.text = "Text"..i
subInfo.value = i
subInfo.func = selectFunction
tinsert(info.list, subInfo)
end
self:ddAddButton(info, level)
end)local lsfdd = LibStub("LibSFDropDown-1.5")
local menu = lsfdd:SetMixin({})
menu:ddHideWhenButtonHidden(parentFrame)
menu:ddSetMaxHeight(180)
local check = random(10)
local menuList = {}
local menuListFunc = function(btn) check = btn.value end
local menuListChecked = function(btn) return check == btn.value end
for i = 1, 10 do
menuList[i] = {
text = "test text "..i,
value = i,
checked = menuListChecked,
func = menuListFunc,
}
end
menuList[11] = {
text = "test",
menuList = {
{
notCheckable = true,
text = "wow",
func = function() print("wow") end,
},
},
}
parentFrame:SetScript("OnMouseDown", function(self, button)
if button ~= "RightButton" then return end
menu:ddEasyMenu(menuList, "cursor", nil, nil, "menu")
end)local lsfdd = LibStub("LibSFDropDown-1.5")
local media = LibStub("LibSharedMedia-3.0")
local background = lsfdd:CreateMediaBackgroundButton(parentFrame, 120) -- BACKGROUND
background:SetPoint("TOPRIGHT", -20, -20)
background:ddSetSelectedValue(currentValue or media:GetDefault("background"))
background:ddSetOnSelectedFunc(function(value)
local texture = media:Fetch("background", value)
print(value, texture)
-- some code
end)
local border = lsfdd:CreateMediaBorderButton(parentFrame, 120) -- BORDER
border:SetPoint("TOPLEFT", background, "BOTTOMLEFT", 0, -10)
border:ddSetSelectedValue(currentValue or media:GetDefault("border"))
border:ddSetOnSelectedFunc(function(value)
local texture = media:Fetch("border", value)
print(value, texture)
-- some code
end)
local statusbar = lsfdd:CreateMediaStatusbarButton(parentFrame, 120) -- STATUSBAR
statusbar:SetPoint("TOPLEFT", border, "BOTTOMLEFT", 0, -10)
statusbar:ddSetSelectedValue(currentValue or media:GetDefault("statusbar"))
statusbar:ddSetOnSelectedFunc(function(value)
local texture = media:Fetch("statusbar", value)
print(value, texture)
-- some code
end)
local font = lsfdd:CreateMediaFontButton(parentFrame, 120) -- FONT
font:SetPoint("TOPLEFT", statusbar, "BOTTOMLEFT", 0, -10)
font:ddSetSelectedValue(currentValue or media:GetDefault("font"))
font:ddSetOnSelectedFunc(function(value)
local selectedFont = media:Fetch("font", value)
print(value, selectedFont)
-- some code
end)
local sound = lsfdd:CreateMediaSoundButton(parentFrame, 120) -- SOUND
sound:SetPoint("TOPLEFT", font, "BOTTOMLEFT", 0, -10)
sound:ddSetSelectedValue(currentValue or media:GetDefault("sound"))
sound:ddSetOnSelectedFunc(function(value)
local selectedSound = media:Fetch("sound", value)
print(value, selectedSound)
-- some code
end)