TextInput

Extends: UiWidget

A focusable single-line text entry widget. Characters arrive via onECPKeyboard() (Roku's mobile-app keyboard sends individual characters this way), or from a BGE.UI.Keyboard on-screen keyboard - set keyboard so OK opens one. Left/Right (while focused) move the caret, a keyboard's Backspace deletes before it, and OK or a keyboard's Enter fires onSubmit.

Properties

  • text (string) — Current text content.
  • cursorIndex (integer) — Caret position, 0..Len(text). Moved by Left/Right while focused, and
  • maxLength (integer) — Maximum text length, 0 = unlimited. A character typed once text.Len()
  • placeholder (string) — Text shown (dimmed) when text is empty and this widget isn't focused.
  • keyboard (BGE.UI.Keyboard) — Optional on-screen keyboard: when set, OK opens it (in this input's container) instead of
  • editing (boolean) — True while an on-screen keyboard types into this - draws the caret even when unfocused.
  • onChanged (function | dynamic) — Called after any edit (insert/delete) - function(input as TextInput) as void
  • onSubmit (function | dynamic) — Called on OK-press while focused - function(input as TextInput) as void
  • lastChangedValue (dynamic) — Test accessor: last value an onChanged callback stashed here. Not part
  • drawableText (BGE.DrawableText)
  • repeatThrottle (BGE.UI.RepeatThrottle) — Throttles repeat-while-held Left/Right to one step per

Constructor

new TextInput(game: BGE.Game): TextInput

Parameters


Instance Methods

getValue(): dynamic

Returns

  • dynamic

onECPKeyboard(char: integer): void

Parameters

  • char (integer)

Returns

  • void

insertChar(char: integer): void

Inserts a character at the caret and fires onChanged. Dropped once maxLength is reached.

Parameters

  • char (integer) — character code

Returns

  • void

submit(): void

Fires onSubmit.

Returns

  • void

deleteBeforeCursor(): void

Deletes the character before the caret and fires onChanged.

Returns

  • void

handleInput(input: BGE.GameInput): boolean

Parameters

Returns

  • boolean

onClick(): void

Returns

  • void

draw(parent?: UiWidget): void

Parameters

  • parent (UiWidget, optional, default: "invalid")

Returns

  • void