Skip to content

Input : VisualElement

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.

Properties

PropertyTypeDefaultDescription
textstring-The current text content of the input
cursorPosnumber1The current cursor position in the text
viewOffsetnumber0The horizontal scroll offset for viewing long text
maxLengthnumber?nilMaximum length of input text (optional)
placeholderstring...Text to display when input is empty
placeholderColorcolorgrayColor of the placeholder text
focusedBackgroundcolorblueBackground color when input is focused
focusedForegroundcolorwhiteForeground color when input is focused
patternstring?nilRegular expression pattern for input validation
cursorColornumbernilColor of the cursor
replaceCharstringnilCharacter to replace the input with (for password fields)

Functions

MethodReturnsDescription
Input:blur-
Input:focus-
Input:setCursor-
Input:updateViewportInputUpdates the input's viewport

Protected Functions

MethodReturnsDescription
Input:charbooleanHandles char events
Input:initInputInitializes the Input instance
Input:keybooleanHandles key events
Input:mouse_clickbooleanHandles mouse click events
Input:render-Renders the input element

Input:blur()

Input:focus()

Input:setCursor()

Input:updateViewport()

Updates the input's viewport

Returns

  • Input self The updated instance

Released under the MIT License.