Created
June 11, 2024 22:57
-
-
Save Meorawr/fb082a52fac7080c9dcc867242c82d45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local DropdownButton; | |
local FilterEditBox = CreateFrame("EditBox", nil, nil, "InputBoxTemplate"); | |
FilterEditBox:SetAutoFocus(false); -- Aside; this default has always plagued me. | |
local DefaultMenuMixin = MenuVariants.GetDefaultMenuMixin(); | |
local CustomMenuMixin = CreateFromMixins(DefaultMenuMixin); | |
function CustomMenuMixin:Generate() | |
DefaultMenuMixin.Generate(self); | |
FilterEditBox:ClearAllPoints(); | |
FilterEditBox:SetParent(self); | |
FilterEditBox:SetPoint("TOPLEFT", 8, -8); | |
FilterEditBox:SetPoint("TOPRIGHT", -8, -8); | |
FilterEditBox:SetHeight(20); | |
FilterEditBox:SetScript("OnTextChanged", function(_, userInput) | |
if userInput then | |
DropdownButton:GenerateMenu(); | |
end | |
end) | |
end | |
function CustomMenuMixin:GetInset() | |
local l, t, r, b = DefaultMenuMixin.GetInset(self); | |
t = t + 30; | |
return l, t, r, b; | |
end | |
DropdownButton = CreateFrame("DropdownButton", nil, UIParent, "WowStyle1DropdownTemplate"); | |
DropdownButton:SetPoint("CENTER"); | |
DropdownButton:SetDefaultText("rawr"); | |
DropdownButton.menuMixin = CustomMenuMixin; -- No SetMenuMixin method that I can see? | |
DropdownButton:SetupMenu(function(_, rootDescription) | |
local options = { { "Option 1", 1 }, { "Option 2", 2 }, { "Option 3", 3 } }; | |
for _, option in ipairs(options) do | |
if option[2] >= (FilterEditBox:GetNumber() or 0) then | |
rootDescription:CreateButton(option[1], print, option[2]); | |
end | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment