Inputs
Inputs can be used to collect text user input.
Playground
Notification Sound ID
Usage
You can create an Input by calling the AddInput method on a Groupbox.
Arguments
LeftGroupBox:AddInput("MyTextbox", {
Default = "My textbox!",
Numeric = false, -- true / false, only allows numbers
Finished = false, -- true / false, only calls callback when you press enter
ClearTextOnFocus = true, -- true / false, if false the text will not clear when textbox focused
Text = "This is a textbox",
Tooltip = "This is a tooltip", -- Information shown when you hover over the textbox
Placeholder = "Placeholder text", -- placeholder text when the box is empty
-- MaxLength is also an option which is the max length of the text
Callback = function(Value)
print("[cb] Text updated. New text:", Value)
end,
})| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Index/ID of the option | string | nil |
| 2 | Input configuration table | table | nil |
Configuration Table
Prop
Type
Methods
You can use the following methods to interact with the textbox:
SetValue
Sets the input value.
Input:SetValue(text)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | The new value of the input | string | nil |
SetText
Updates the input's label text.
Input:SetText(text)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | The new text of the input | string | nil |
SetDisabled
Enables or disables the input.
Input:SetDisabled(boolean)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Whether to disable the input | boolean | nil |
SetVisible
Shows or hides the input.
Input:SetVisible(boolean)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Whether to show the input | boolean | nil |
OnChanged
Adds another callback function to the input. This is the recommended way to listen for changes in the input.
Input:OnChanged(function)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | The callback function | function | nil |
Example
local Options = Library.Options
local Toggles = Library.Toggles
-- Setup UI elements first
local MyInput = Groupbox:AddInput("MySoundID", {
Text = "Notification Sound ID",
Placeholder = "rbxassetid://",
Default = "rbxassetid://",
})
-- Then after creating all UI elements, add callbacks
-- MyInput:OnChanged(...) also works
Options.MyInput:OnChanged(function(state)
-- Options.MyInput.Value == state
print("Input changed to " .. Options.MyInput.Value)
end)