2.8 KiB
2.8 KiB
Input
This is the input class. It provides a text input field that can handle user input with various features like cursor movement, text manipulation, placeholder text, and input validation.
Extends: VisualElement
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| text | string | - | The current text content of the input |
| cursorPos | number | 1 | The current cursor position in the text |
| viewOffset | number | 0 | The horizontal scroll offset for viewing long text |
| placeholder | string | ... | Text to display when input is empty |
| placeholderColor | color | gray | Color of the placeholder text |
| focusedBackground | color | blue | Background color when input is focused |
| focusedForeground | color | white | Foreground color when input is focused |
| cursorColor | number | nil | Color of the cursor |
| replaceChar | string | nil | Character to replace the input with (for password fields) |
Functions
| Method | Returns | Description |
|---|---|---|
| Input.new | Input | Creates a new Input instance |
| Input:Input | Input | Initializes the Input instance |
| Input:Input | - | Sets the cursor position and color |
| Input:Input | boolean | Handles char events |
| Input:Input | boolean | Handles key events |
| Input:Input | boolean | Handles mouse click events |
| Input:Input | Input | Updates the input's viewport |
| Input:Input | - | Handles a focus event |
| Input:Input | - | Handles a blur event |
| Input:Input | - | Handles paste events |
| Input:Input | - | Renders the input element |
Input.new()
Returns
InputobjectThe newly created Input instance
Input:Input(props, basalt)
Parameters
propstableThe properties to initialize the element withbasalttableThe basalt instance
Returns
InputselfThe initialized instance
Input:Input(x, y, blink, color)
Sets the cursor position and color
Parameters
xnumberThe x position of the cursorynumberThe y position of the cursorblinkbooleanWhether the cursor should blinkcolornumberThe color of the cursor
Input:Input(char)
Parameters
charstringThe character that was typed
Returns
booleanhandledWhether the event was handled
Input:Input(key)
Parameters
keynumberThe key that was pressed
Returns
booleanhandledWhether the event was handled
Input:Input(button, x, y)
Parameters
buttonnumberThe button that was clickedxnumberThe x position of the clickynumberThe y position of the click
Returns
booleanhandledWhether the event was handled
Input:Input()
Updates the input's viewport
Returns
InputselfThe updated instance