A skinnable text input handler.
Supports text selection, keyboard cursor navigation, as well as basic hotkeys: Ctrl + Z, Ctrl + Y for undo and redo and Ctrl + A to select all text.
Static methods
Constructor
new(font:Font, ?parent:Object)
Create a new TextInput instance.
Parameters:
font | The font used to render the text. |
|---|---|
parent | An optional parent |
Variables
backgroundColor:Null<Int>
If set, TextInput will render provided color as a background to text interactive area.
canEdit:Bool = true
When disabled, user would not be able to edit the input text (selection is still available).
cursorIndex:Int = -1
Current position of the input cursor. When TextInput is not focused value is -1.
inputWidth:Null<Int>
Maximum input width.
Contrary to Text.maxWidth does not cause a word-wrap, but also masks out contents that are outside the max width.
selectionTile:Tile
The Tile used to render the background for selected text. When rendering, this Tile is stretched horizontally to fill entire selection area.
Methods
getCursorLine(line:Int):Int
Convert a text line number into a display line number. First line is 0. See getTextPos() and getCursorPos().
getSelectedText():String
Returns a String representing currently selected text area or null if no text is selected.
getTextPos(cursor:Int):Int
When lineBreak is enabled and some word wrapping operation applies, the cursorIndex no longer represent the position in the exact text but in the wrapped text, including inserted newlines. This function allows to translate the cursor position into the position into the text. Use getCursorPos to convert the text position into a cursor position.
dynamicisWordLimit(pos:Int):Bool
This function is used to code the behavior of Ctrl-Left/Right word skipping. By default it uses charset.isSpace but can be customized.
