PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

TextBoxFocused

The TextBoxFocused event fires when a gains focus on a TextBox - typically when a client clicks/taps on a text box to begin inputting text. This also fires if a text box focus is focused using TextBox/CaptureFocus.

For example, the code below prints the the name of the TextBox focused when the event fires.

local UserInputService = game:GetService("UserInputService")

function TextBoxFocused(textbox)
	print(textbox.Name)
end)

UserInputService.TextBoxFocused:Connect(TextBoxFocused)

It can be used alongside UserInputService/FocusReleased to track when a text box gains and loses focus.

As this event only fires locally, it can only be used in a LocalScript.

See also

  • UserInputService/GetFocusedTextBox
  • TextBox/Focused
  • TextBox/FocusLost

Parameters

Name Type Default Description

The TextBox that gained focus


Code Samples


Modifying a TextBox on Focused and FocusReleased

This example adjusts the GuiObject/Transparency|transparency of TextBox|TextBoxes when they gain and lose focus using.

When a text box UserInputService/TextBoxFocused|gains focus, it’s transparency deceases. When a text box UserInputService/TextBoxFocusReleased|loses focus, it’s transparency increases. This is similar to how the default chat window increases and decreases transparency when a user starts and stops interacting with it.

In order for this example to work as expected, it should be placed in a LocalScript.