Control:InsertText

Inserts text at the current selection.

Syntax

Signature
Control:InsertText(Text: string) -> ()

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
TextstringText to insert at the current selection.

Returns

TypeDescription
()None.

Notes

Converts CRLF and CR line endings to LF and truncates inserted text to fit MaxLength without splitting a UTF-8 continuation sequence. This programmatic method does not require focus.

Example

Luau
local Box = Drawing.create("TextBox", {Text = "Old text"})
Box:SelectAll()
Box:InsertText("Replacement")
print(Box.Text)

Box:InsertText(" with more text")
print(Box.Text)
Box:Destroy()