LogoObsidian

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 IdxArgument DescriptionTypeDefault
1Index/ID of the optionstringnil
2Input configuration tabletablenil

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 IdxArgument DescriptionTypeDefault
1The new value of the inputstringnil

SetText

Updates the input's label text.

Input:SetText(text)
Arg IdxArgument DescriptionTypeDefault
1The new text of the inputstringnil

SetDisabled

Enables or disables the input.

Input:SetDisabled(boolean)
Arg IdxArgument DescriptionTypeDefault
1Whether to disable the inputbooleannil

SetVisible

Shows or hides the input.

Input:SetVisible(boolean)
Arg IdxArgument DescriptionTypeDefault
1Whether to show the inputbooleannil

OnChanged

Adds another callback function to the input. This is the recommended way to listen for changes in the input.

Input:OnChanged(function)
Arg IdxArgument DescriptionTypeDefault
1The callback functionfunctionnil

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)

On this page