Text Input
Capture a string on focus loss, optionally requiring Enter.
Create Text Input#
Capture a string on focus loss, optionally requiring Enter.
The constructor returns a TextInput handle. The snippet assumes section exists, as created in Quick start.
local input = section:CreateTextInput({
Name = "Profile note", Flag = "note", Default = "", Placeholder = "Write a note",
SubmitOnEnter = true,
Callback = function(value) print("Submitted:", value) end,
})
Open full size ↗Arguments#
| Option | Type | Default | Meaning |
|---|---|---|---|
| Default | string | "" | Initial text. |
| Placeholder | string | "" | Hint for an empty field. |
| SubmitOnEnter | boolean | false | If true, FocusLost submits only after Enter. |
| Callback | function(string) | nil | Receives submitted text. |
Also accepts common options: Name, Description, Disabled and Callback; stateful controls additionally support Flag, Persist and Sensitive.
Manage state#
input:SetValue("Local note")
print(input:GetValue())
input:SetDisabled(true)Returned methods#
| Method | Returns | Behavior |
|---|---|---|
| GetValue() | string | Current string value. |
| SetValue(value, notify?) | self | Silent by default; true calls Callback only after a changed normalized value. |
| SetDisabled(boolean) | self | Changes user availability without discarding the value. |
| IsDisabled() | boolean | Reads the requested disabled state. |
| Destroy() | nil | Removes this control and its subscriptions; safe to repeat. |
Behavior and limitations#
This is a string input, not a numeric validator, password field or multiline editor. Do validation in your callback.
AutoSave tracks the Text property while typing, independent of Enter submission. FocusLost can submit an unchanged string again.
Configuration serialization limits text to 16 KiB of UTF-8 bytes. Sensitive=true excludes a flag from snapshots; it does not mask the on-screen field or encrypt text.
Default, Placeholder and SetValue require strings. SubmitOnEnter and notify require booleans when supplied; invalid types assert. Text length is constrained when saving configuration, not by an on-screen character limit.