import{_ as o,C as t,o as p,c as r,k as a,a as s,H as n,Q as e}from"./chunks/framework.4313453f.js";const B=JSON.parse('{"title":"Input","description":"","frontmatter":{},"headers":[],"relativePath":"references/input.md","filePath":"references/input.md","lastUpdated":null}'),c={name:"references/input.md"},d=e(`
Input elements allow users to enter text or data. They are commonly used in forms and text entry fields to gather user input.
Input inherit from VisualElement and BasicElement
| Property | Type | Description |
|---|---|---|
| value | string | The current text inside the input field. |
| cursorIndex | number | Position of the cursor within the text. |
| scrollIndex | number | The index from which the visible text starts, useful for longer inputs. |
| inputLimit | number | Maximum number of characters the input field can accept. |
| inputType | string | Defines the nature of input, e.g., 'text', 'password', 'number'. |
| placeholderText | string | Placeholder text, which is beeing displayed when there's no value. |
| placeholderColor | color | Text color for placedholder text. |
| placeholderBackground | color | Background color for placeholder text. |
| Method | Returns | Description |
|---|---|---|
| onChange | self | Gets triggered as soon as the value changes. |
| Method | Returns | Description |
|---|---|---|
| setPlaceholder | self | Changes placeholder text, color and background. |
| getPlaceholder | multiple | Returns placeholder text, color and background. |
local main = basalt.getMainFrame()
local userInput = main:addInput()
userInput:setInputLimit(12)
userInput:setInputType("password")local main = basalt.getMainFrame()
local userInput = main:addInput()
userInput:setInputLimit(12)
userInput:setInputType("password")Registers a new custom event listener which triggers on value change.
function - The function to call when the event triggers.self - The element itself.local main = basalt.getMainFrame()
local input = main:addInput()
local function valueChange(self, value)
basalt.debug("Value has changed to "..value)
end
input:onChange(valueChange)local main = basalt.getMainFrame()
local input = main:addInput()
local function valueChange(self, value)
basalt.debug("Value has changed to "..value)
end
input:onChange(valueChange)Changes the placeholder text, color and background.
string - The placeholder text.color? - The text color of the placeholder text.color? - The background color.self - The element itself.local main = basalt.getMainFrame()
main:addInput():setPlaceholder("...", colors.gray)local main = basalt.getMainFrame()
main:addInput():setPlaceholder("...", colors.gray)Returns the placeholder text, color and background.
string - The placeholder text.color - The text color of the placeholder text.color - The background color.local main = basalt.getMainFrame()
local input = main:addInput():setPlaceholder("...", colors.gray)
basalt.debug(input:getPlaceholder())local main = basalt.getMainFrame()
local input = main:addInput():setPlaceholder("...", colors.gray)
basalt.debug(input:getPlaceholder())