Skip to content
Benedict Allen edited this page Nov 17, 2015 · 4 revisions

TextInput Class

The TextInput is a clickable object with word wrapped text (centre aligned by default).

Extends Sheet

Style options

  • colour - The background colour.
  • colour.focussed - The background colour when focussed.
  • colour.highlighted - The background colour of highlighted text.
  • textColour - The text colour.
  • textColour.focussed - The text colour when focussed.
  • textColour.highlighted - The text colour of highlighted text.
  • mask - The text masking.
  • mask.focussed - The text masking when focussed.

Constructor

TextInput( number x, number y, number width )

Callbacks

Note, this element uses the onPreDraw(), onMouseEvent(), onTextEvent(), and onKeyboardEvent() callbacks of Sheet.

onEnter

TextInput:onEnter()

Called when enter is pressed while the input is focussed. The input will be moved out of focus when onEnter is called.

onTab

TextInput:onTab()

Called when tab is pressed while the input is focussed. The input will be moved out of focus when onTab is called.

onFocus

TextInput:onFocus()

Called when the input is focussed on.

onUnFocus

TextInput:onUnFocus()

Called when the input is unfocussed from.

Properties

text

TextInput.text - string

The text shown by the input.

scroll

TextInput.scroll - number

The current horizontal scrolling of the input.

focussed

TextInput.focussed - boolean

Whether the input is currently focussed.

cursor

TextInput.cursor - number

The cursor position of the input (0 being first character, 1 being the second).

Methods

setText

This method is chainable.

TextInput self = TextInput:setText( string text )

Sets the text of the input.

setScroll

This method is chainable.

TextInput self = TextInput:setScroll( number scroll )

Sets the horizontal scroll of the input.

setCursor

This method is chainable.

TextInput self = TextInput:setCursor( number cursor )

Sets the cursor position of the input and handles scrolling.

setSelection

This method is chainable.

TextInput self = TextInput:setSelection( number position )

Sets the selection position of the input.

getSelectedText

string text or false = TextInput:getSelectedText()

Returns the selected text of the input, or false if nothing is selected.

write

This method is chainable.

TextInput self = TextInput:write( string text )

Writes text to the input, replacing selected text if necessary, and updating the cursor position.

focus

This method is chainable.

TextInput self = TextInput:focus()

Focusses on the element, invoking callbacks.

unfocus

This method is chainable.

TextInput self = TextInput:unfocus()

Unfocusses from the element, invoking callbacks.

Clone this wiki locally