PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

WindowFocused

WindowFocused fires immediately when the user starts interacting with the PluginGui’s window, usually by clicking on it. This functions works similarly to the similarly-named UserInputService/WindowFocused event. It fires before any GuiObject/InputBegan events related to mouse buttons.

If another PluginGui is in focus and the user focuses this PluginGui, then this event fires after the other’s PluginGui/WindowFocusReleased|WindowFocusReleased event. However, if the main game window was in focus, this event fires after UserInputService/WindowFocusReleased.


Code Samples


Detecting PluginGui Focus State

This code sample demonstrates how the focus state of a PluginGui can be tracked using the PluginGui/WindowFocused|WindowFocused and PluginGui/WindowFocusReleased|WindowFocusReleased events. It changes the PluginGui/Title|Title as the focus state changes.

local dwpgi = DockWidgetPluginGuiInfo.new(
	Enum.InitialDockState.Float,
	true, true, 200, 50, 1, 1
)

local widget = plugin:CreateDockWidgetPluginGui("TestWidget", dwpgi)

widget.WindowFocusReleased:Connect(function (...)
	widget.Title = "I'm not in focus :("
end)
widget.WindowFocused:Connect(function (...)
	widget.Title = "I'm in focus :D"
end)