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:setCursor-Sets the cursor position and color
Input:updateViewportInputUpdates the input's viewport

Protected Functions

MethodReturnsDescription
Input:blur-Handles a blur event
Input:charbooleanHandles char events
Input:focus-Handles a focus event
Input:initInputInitializes the Input instance
Input:keybooleanHandles key events
Input:mouse_clickbooleanHandles mouse click events
Input:render-Renders the input element

Sets the cursor position and color

Parameters

  • x number The x position of the cursor
  • y number The y position of the cursor
  • blink boolean Whether the cursor should blink
  • color number The color of the cursor

Input:updateViewport()

Updates the input's viewport

Returns

  • Input self The updated instance

Released under the MIT License.