TextInput
UiElement
TextInput is a text input element
pos.gui.TextInput(x: number, y: number, w: number, background: number|nil, foreground: number|nil, text: string, onEnter: function|nil)
Creates a new TextInput at the given location with given width.
If background
or foreground
is nil
, they are set as the defaults: colors.gray
and colors.white
respectively.
onEnter
is called if enter is pressed while the input is focused and is given the current text.
Type | Name | Description |
---|---|---|
number |
bg |
Background color |
number |
fg |
Foreground color (text color) |
number |
w |
Max line length |
number |
h |
Number of lines |
function |
onEnter |
Callback for input submitted |
string |
text |
Current text in input (Read Only) |
boolean |
focused |
If the input is currently focused |
UiElement|nil |
next |
The next element to focus |
boolean |
submitable |
If the input should submit on enter, or add a new line |
boolean |
hideText |
If input text should be replaced with * s |
string |
type |
Override. type is 'TextInput' |
Type | Name | Description |
---|---|---|
table |
_lines |
Text split into lines by length and newline, used for drawing |
boolean |
_focusedNext |
If the element should be focused after this event |
Return | Name | Description |
---|---|---|
nil |
draw(window: Window) |
Override. Draws the input |
nil |
process(event: table, window: Window) |
Override. Processes mouse_click , char , and key events |
nil |
setText(text: string) |
Sets the text and splits into lines |
nil |
setHeight(height: number) |
Sets the maximum height of the input |