How can I detect if a TextBox loses focus in a plugin widget?

I want to detect if a TextBox loses focus in a plugin widget, but TextBox.FocusLost doesn’t work for me. I’m getting no errors or warnings, but the code inside of the event isn’t being ran.

Here’s the code for that event:

-- Note: PublishingFrame and VerifyIdentity are Frames; Code is the TextBox
PublishingFrame.VerifyIdentity.Code.FocusLost:Connect(function(enterPressed)
     print("SAD!");
end);

I tried using UserInputService.TextBoxFocusReleased, but that didn’t work either.

Here’s the code I tried for that event:

game:GetService("UserInputService").TextBoxFocusReleased:Connect(function(textBox)
    print("SAD!");
end);

This works on GUIs in-game, but not plugins for some reason.

The roblox developer website explains this topic, it says that UserInputService and ContextActionService don’t work with widget plugins.

They give us a workaround for this, they state:

One workaround for generic input events is to create a transparent Frame and overlay it over the entire screen. When the user clicks on the frame, keyboard input will be captured in the GuiObject.InputBegan event on the frame until the user clicks away. Below is a sample code snippet that creates such a frame:

You can read the full article here (end of the page)

1 Like

Ah shoot, that stinks. Thank you for posting the article!