TextArea

TextArea is a multi-line text field with multiple text-wrapping modes.

Constructor

new TextArea()

Creates an instance of TextArea object.

Classes

TextArea

Members

(readonly) WrapStyle :number

Enum for word wrapping styles. Used with lineWrap() to control how text is wrapped.

Type:
  • number
Properties
NameTypeDescription
Nonenumber

Disable line wrapping.

Wordnumber

Wrap when a full word doesn't fit.

Characternumber

Wrap when a character doesn't fit.

Example
TextArea.WrapStyle.Word

Methods

lineWrap(valueopt) → {TextArea.WrapStyle|TextArea}

Sets or gets line wrapping mode. Line wrapping helps to display long lines without having to scroll horizontally.

Parameters:
NameTypeAttributesDescription
valueTextArea.WrapStyle<optional>

One of: TextArea.WrapStyle.Word, TextArea.WrapStyle.Character, TextArea.WrapStyle.None (default).

Returns:

When setting a value, this TextArea component is returned; otherwise a current wrapping mode is returned.

Type: 
TextArea.WrapStyle | TextArea

text(textopt, actionopt, insert_positionopt) → {string|TextArea}

Sets or Gets the text value of the text area.

Parameters:
NameTypeAttributesDefaultDescription
textstring<optional>

Text value to replace existing text.

actionTextAction<optional>
TextAction.Set

Specific action to perform with text. One of: TextAction.Set, TextAction.Prepend, TextAction.Append, TextAction.Insert, TextAction.ReplaceSelection.

insert_positionnumber<optional>
undefined)

Position where to insert text. Applies only if action argument is TextAction.Insert.

Returns:

When setting text, this TextArea component is returned; otherwise current text is returned.

Type: 
string | TextArea
Example
const txt = textarea.text(); // gets text value
textarea.text("New Text"); // sets new text value
textarea.text("Appended Text", TextAction.Append); // Appends new text to the end of current text
textarea.text("Inserted Text", TextAction.Insert); // Inserts at current caret position
textarea.text("Inserted Text", TextAction.Insert, textarea.caretPosition() - 50); // Inserts at specified position
textarea.text("New Text", TextAction.ReplaceSelection); // Replaces selected text or inserts at current cursor position if no text is selected