Skip to content

TextBox : VisualElement

A multi-line text editor component with cursor support and text manipulation features

Properties

PropertyTypeDefaultDescription
linestable{}Array of text lines
cursorXnumber1Cursor X position
cursorYnumber1Cursor Y position (line number)
scrollXnumber0Horizontal scroll offset
scrollYnumber0Vertical scroll offset
editablebooleantrueWhether text can be edited
syntaxPatternstable{}Syntax highlighting patterns
cursorColornumbernilColor of the cursor

Functions

MethodReturnsDescription
TextBox:addSyntaxPatternTextBoxAdds a new syntax highlighting pattern
TextBox:getTextstringGets the text of the TextBox
TextBox:setTextTextBoxSets the text of the TextBox
TextBox:updateViewportTextBoxUpdates the viewport to keep the cursor in view

Protected Functions

MethodReturnsDescription
TextBox:charbooleanHandles character input
TextBox:initTextBoxInitializes the TextBox instance
TextBox:keybooleanHandles key events
TextBox:mouse_clickbooleanHandles mouse click events
TextBox:mouse_scrollbooleanHandles mouse scroll events
TextBox:render-Renders the TextBox with syntax highlighting

TextBox:addSyntaxPattern(pattern, color)

Adds a new syntax highlighting pattern

Parameters

  • pattern string The regex pattern to match
  • color colors The color to apply

Returns

  • TextBox self The TextBox instance

TextBox:getText()

Gets the text of the TextBox

Returns

  • string text The text of the TextBox

TextBox:setText(text)

Sets the text of the TextBox

Parameters

  • text string The text to set

Returns

  • TextBox self The TextBox instance

TextBox:updateViewport()

Updates the viewport to keep the cursor in view

Returns

  • TextBox self The TextBox instance

Released under the MIT License.