Input
A text field. Fires on every keystroke, or only when the user is done typing.
The smallest input#
main:Input({
Text = "Target player",
Callback = function(text)
target = text
end,
})Live preview
My Script
v1.0
Search…
Main
Visuals
Settings
Filter
Building it up#
Hint at what goes in it:
main:Input({
Text = "Target player",
Placeholder = "Username…",
Callback = setTarget,
})Wait until they finish typing — fires on blur or Enter instead of every keystroke:
main:Input({
Text = "Target player",
Placeholder = "Username…",
FireOnBlur = true,
Callback = setTarget,
})Every option#
| Option | Type | Default | What it does |
|---|---|---|---|
Textreq | string | — | The label. |
Callback | function(string) | — | Called with the field's contents. |
Placeholder | string | — | Ghost text shown while the field is empty. |
Default | string | "" | Starting contents. |
FireOnBlur | boolean | false | Fire on blur or Enter instead of on every keystroke. |
Style | string | — | Visual variant, matching the button styles. |
Description | string | — | A quieter second line. |
Icon | string | — | An icon shown before the label. |
Save | string | — | Persist under this key. |
Methods#
| Method | Returns | What it does |
|---|---|---|
Get() | string | The current contents |
Set(text) | — | Replaces the contents and fires Callback |
Which firing mode to use#
Per keystroke is right when the result is cheap and instant feedback is the point:
-- Filtering a list narrows as you type. Correct.
main:Input({ Text = "Filter", Callback = function(q) applyFilter(q) end })FireOnBlur is right when a half-typed value is meaningless or costly:
-- Without FireOnBlur this fires on "S", then "St", then "Ste"…
main:Input({ Text = "Teleport to", FireOnBlur = true, Callback = teleportTo })