Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions PhanxConfig-Dropdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
credits line -- any modified versions must be renamed to avoid conflicts.
----------------------------------------------------------------------]]

local MINOR_VERSION = 20170904
local MINOR_VERSION = 20201001

local lib, oldminor = LibStub:NewLibrary("PhanxConfig-Dropdown", MINOR_VERSION)
if not lib then return end
Expand All @@ -30,12 +30,17 @@ local function OpenDropdown(dropdown)
dropdown.list = list
end

for i = 1, #lib.listFrames do
lib.listFrames[i].isActive = false
end

local show = not list:IsShown()
CloseDropDownMenus()

if show then
list:Show()
list:Raise()
list.isActive = true
local selectedIndex
local items, selected = dropdown.items, dropdown.selected
for i = 1, #items do
Expand All @@ -54,7 +59,9 @@ end

local function CloseDropdowns(_, _, dropDownFrame, _, _, _, _, clickedButton)
for i = 1, #lib.listFrames do
lib.listFrames[i]:Hide()
if not lib.listFrames[i].isActive then
lib.listFrames[i]:Hide()
end
end
end

Expand Down Expand Up @@ -83,6 +90,7 @@ end

local function Frame_OnHide(self)
if self.list then
self.list.isActive = false
self.list:Hide()
end
end
Expand All @@ -92,6 +100,7 @@ end
local function ListButton_OnClick(self)
local dropdown = self:GetParent():GetParent()
dropdown.selected = self.value
dropdown.list.isActive = false
dropdown.list:Hide()

dropdown.valueText:SetText(self:GetText() or self.value)
Expand Down Expand Up @@ -247,7 +256,7 @@ function CreateList(dropdown) -- local

id = id + 1

local list = CreateFrame("Button", "PhanxConfigDropdown" .. id, dropdown)
local list = CreateFrame("Button", "PhanxConfigDropdown" .. id, dropdown, BackdropTemplateMixin and "BackdropTemplate")
list:SetFrameStrata("DIALOG")
list:SetToplevel(true)
list:Hide()
Expand Down