Plugin Help with Bind to Close

To start, I am very new to making plugins: this is only my second attempt.

Here is my current code:

local mainToolbar = plugin:CreateToolbar("EasyLS")
local toggleEditorButton = mainToolbar:CreateButton("EasyLS Pattern Editor", "Open EasyLS pattern editor.","")

local widgetInfo = DockWidgetPluginGuiInfo.new(
	Enum.InitialDockState.Float,  -- Widget will be initialized in floating panel
	false,   -- Widget will be initially enabled
	false,  -- Don't override the previous enabled state
	500,    -- Default width of the floating window
	250,    -- Default height of the floating window
	500,    -- Minimum width of the floating window (optional)
	250     -- Minimum height of the floating window (optional)
)

local mainPluginUI = plugin:CreateDockWidgetPluginGui("EasyLSEditor", widgetInfo)
mainPluginUI.Title = "EasyLS Pattern Editor"

mainPluginUI:BindToClose(function()
	toggleEditorButton:SetActive(false)
end)

toggleEditorButton.Click:Connect(function()
	mainPluginUI.Enabled = not mainPluginUI.Enabled
end)

Problem: Whenever you click the X button in the DockWidgetPluginGui menu, the toggleEditorButton still recognizes the menu as open
EasyLS Pattern Editor (gyazo.com)
As you can see in that gif, I close the menu with the X button, but the button I used to open the menu still shows the menu as open.

My Attempted Solution: Manually detect when the X button is clicked with bind to close, and unshade the button using the :SetActive property

Problem With Solution:

:BindToClose is a function of PluginUI as seen here. So I am unsure why its “not a member”.

2 Likes

That’s… Strange,

I tried inserting the plugin into my studio and whenever I click the x, no such error appears and the button gets deactivated.

Do you have any betas enabled?

1 Like