TextBox

An editable text control.

Syntax

Signature
Drawing.create("TextBox", Properties: table?) -> DrawingControl

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
Propertiestable?Initial property values. Omitted properties use the defaults below.

Returns

TypeDescription
DrawingControlA live control. Call Destroy to remove it and its descendants.

Properties

Inherits the shared layout properties. Positions are relative to Parent. BackgroundTransparency is 0 for opaque and 1 for transparent.

PropertyTypeDefault / behavior
TextstringDefaults to ""; up to 65536 UTF-8 bytes.
TextColor3Color3Defaults to RGB(235, 235, 238).
TextSizenumberDefaults to 16 pixels.
FontnumberDefaults to Drawing.Fonts.Monospace.
PaddingnumberDefaults to 6 pixels.
PlaceholderTextstringDefaults to ""; shown while the empty field is unfocused.
PlaceholderColor3Color3Defaults to RGB(130, 130, 138).
TextEditablebooleanDefaults to true.
ClearTextOnFocusbooleanDefaults to false.
MultilinebooleanDefaults to false. Enter submits; in multiline mode, Ctrl+Enter submits.
MaxLengthnumberDefaults to 65536 UTF-8 bytes.
Cursor / AnchornumberZero-based UTF-8 byte offsets for the caret and selection; default to 0.

Events

EventArgumentsDescription
Focused()Keyboard focus acquired.
FocusLostsubmitted: booleanFocus released; submitted is true after Enter.
TextChangedtext: stringText changed by editing or property assignment.
InputBegankey: string, control: boolean, shift: booleanA key reached the focused textbox.
MouseButton1Down()Left mouse button pressed inside the control.
MouseButton1Up()Left mouse button released after a press.
MouseButton1Click()Press and release completed inside the control.

Every control supports Changed and GetPropertyChangedSignal(Property). UseDestroy()to remove a control and its children.

Notes

TextEditable controls user editing. Multiline enables multiple lines. Focused, FocusLost, and TextChanged report editing activity.

Example

Luau
local Control = Drawing.create("TextBox", {PlaceholderText = "Enter a message", Size = Vector2.new(280, 32)})
Control.FocusLost:Connect(function(Submitted) if Submitted then print(Control.Text) end end)