Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 17 additions & 4 deletions src/components/ui/Dropdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local Tween = Creator.Tween

local TabBackgroundTransparency = 0.67

function DropdownMenu.New(Config, Dropdown, Element, CanCallback, Type)
function DropdownMenu.New(Config, Dropdown, Element, Type)
local DropdownModule = {}

if not Dropdown.Callback then
Expand Down Expand Up @@ -175,12 +175,22 @@ function DropdownMenu.New(Config, Dropdown, Element, CanCallback, Type)

local function Callback(customCallback)
DropdownModule:Display()
if Dropdown.Locked then
return
end

if Dropdown.Callback then
task.spawn(function()
if Dropdown.Locked then
return
end
Creator.SafeCallback(Dropdown.Callback, Dropdown.Value)
end)
else
task.spawn(function()
if Dropdown.Locked then
return
end
Creator.SafeCallback(customCallback)
end)
end
Expand Down Expand Up @@ -455,7 +465,7 @@ function DropdownMenu.New(Config, Dropdown, Element, CanCallback, Type)

if Type == "Dropdown" then
Creator.AddSignal(TabMain.UIElements.TabItem.MouseButton1Click, function()
if TabMain.Locked then
if Dropdown.Locked or TabMain.Locked then
return
end

Expand Down Expand Up @@ -527,7 +537,7 @@ function DropdownMenu.New(Config, Dropdown, Element, CanCallback, Type)
end)
end
Creator.AddSignal(TabMain.UIElements.TabItem.MouseButton1Click, function()
if TabMain.Locked then
if Dropdown.Locked or TabMain.Locked then
return
end
Callback(Tab.Callback or function() end)
Expand Down Expand Up @@ -580,7 +590,7 @@ function DropdownMenu.New(Config, Dropdown, Element, CanCallback, Type)
RecalculateCanvasSize()

function DropdownModule:Open()
if CanCallback then
if not Dropdown.Locked then
Dropdown.UIElements.Menu.Visible = true
Dropdown.UIElements.MenuCanvas.Visible = true
Dropdown.UIElements.MenuCanvas.Active = true
Expand All @@ -592,6 +602,9 @@ function DropdownMenu.New(Config, Dropdown, Element, CanCallback, Type)

task.spawn(function()
task.wait(0.1)
if Dropdown.Locked then
return
end
Dropdown.Opened = true
end)

Expand Down
9 changes: 4 additions & 5 deletions src/elements/Dropdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ function Element:New(Config)
Dropdown.Value = Dropdown.Values[Dropdown.Value]
end

local CanCallback = true

Dropdown.DropdownFrame = require("../components/window/Element")({
Title = Dropdown.Title,
Desc = Dropdown.Desc,
Expand Down Expand Up @@ -90,7 +88,7 @@ function Element:New(Config)
-- })
end

Dropdown.DropdownMenu = CreateDropdown(Config, Dropdown, Element, CanCallback, "Dropdown")
Dropdown.DropdownMenu = CreateDropdown(Config, Dropdown, Element, "Dropdown")

Dropdown.Display = Dropdown.DropdownMenu.Display
Dropdown.Refresh = Dropdown.DropdownMenu.Refresh
Expand All @@ -114,12 +112,13 @@ function Element:New(Config)

function Dropdown:Lock()
Dropdown.Locked = true
CanCallback = false
if Dropdown.Opened or Dropdown.UIElements.MenuCanvas.Visible then
Dropdown:Close()
end
return Dropdown.DropdownFrame:Lock(Dropdown.LockedTitle)
end
function Dropdown:Unlock()
Dropdown.Locked = false
CanCallback = true
return Dropdown.DropdownFrame:Unlock()
end

Expand Down
Loading