PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

CaptureFocus

Forces the client to focus on the TextBox.

Returns

Return Type Summary

Code Samples


TextBox:CaptureFocus

This code sample causes the client to focus on the parent TextBox when the Q key is pressed by the player.

local ContextActionService = game:GetService("ContextActionService")
local ACTION_NAME = "FocusTheTextBox"
local textBox = script.Parent

local function handleAction(actionName, inputState, inputObject)
	if actionName == ACTION_NAME and inputState == Enum.UserInputState.Begin then
		textBox:CaptureFocus()
	end
end
ContextActionService:BindAction(ACTION_NAME, handleAction, false, Enum.KeyCode.Q)