Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ XR Studio

TextEdit2D

  • Last UpdatedSep 26, 2025
  • 6 minute read

The TextEdit2D node is a multiline text editor. When enabled, it provides core functionalities for text insertion and manipulation, such as: caret movement, text area selection, scrolling, text alignment (left, center, right or justify), margins, and interline offset.

While inserting text, the lines are appropriately split at the last word that fits within the container's width and margins.

The TextEdit2D node inherits from RectBase2D.

Note: Multiple TextEdit2D require proper management of the enabled field in order to focus on the desired node. When two TextEdit2D nodes are enabled, the text input happens on both.

Platform support

This element is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-P WASM platforms.

XR-WIN

XR-P-WIN

XR-P-IOS

XR-P-AND

XR-P-WASM

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Full support

Text formatting and appearance

The appearance of the text can be customized primarly through adjustments to the font, size and color (font, fontColor and fontColorDisabled fields). Additionally, text formatting can be adjusted using margin, interlineOffset and alignment fields.

To facilitate specific scenario, such as password input, maxCharacters, password, passwordChar and returnInText fields are provided. When password field is set to true, the copy and cut functions are disabled.

Note: Currently, the formatting and appearance settings are applied uniformly to the entire text.

Caret management

TextEdit2D supports caret visualization and movement. Its aspect is determined by the textFont size, caretColor and caretThickness values.

The supported caret actions are:

  • Arrow keys move the caret in the arrow direction;

  • Home and End keys move the caret at the beginning or the end of the text, respectively;

  • PageUp and PageDown keys move the caret 10 lines up and down, respectively;

  • Paste the text from the global clipboard field by pressing the Ctrl + V shortcut or by executing the pasteTextFromClipboard SFunction.

The caret can also be positioned by left clicking with the mouse or tapping with a finger on touchscreen devices.

Text area selection

When the enabled field is set to true, the TextEdit2D node allows to select a portion of the visible text by dragging the mouse while holding the left click, or by dragging a finger on touchscreen devices. The color of the area selection can be personalized through the selectionColor field. Additionally, the selectedText field dynamically provides the selected text.

When the text has been selected, it is possible to perform the following actions:

  • Delete the selection with either its respective keys or any other text input. After, the caret will be properly positioned;

  • Cut the selection by pressing the Ctrl + X shortcut or by executing the cutSelectedTextToClipboard SFunction which sets both the global clipboard field and the clipboardText field to the selected text. Finally, the selection is deleted;

  • Copy the selection by pressing the Ctrl + C shortcut or by executing the copySelectedTextToClipboard SFunction which sets both the global clipboard field and the clipboardText field to the selected text.

Any caret movement or positioning cancels the current selection.

Scrolling

Text may exceed the TextEdit2D height, in which case it is possible to navigate with the caret over the upper and lower boundaries. When a boundary is reached, the scrollOffset field is internally calculated to properly visualize the text.

Exploiting the Slider2D node functionalities, it is possible to manually set the scrollOffset value without exceeding its upper limit, which is provided by the maxScrollOffset field and internally calculated.

Given a Slider2D node named Slider and a TextEdit2D node named TextEdit, the following is a sample code for coupling the two components:

<route from="TextEdit.maxScrollOffset" to="Slider.valueScale" />

<route from="Slider.value" to="TextEdit.scrollOffset" />

<route from="TextEdit.scrollOffset" to="Slider.value" />

The Slider2D node's style must be adjusted accordingly.

Code example

This is a code example for the TextEdit2D node.

<TextEdit2D name="myTextEdit2D"

visible="true"

enabled="true"

position="300 300"

fontColor="1 1 1 1"

text="This is the TextEdit2D node in action"

fontColorDisabled="0.5 0.5 0.5 1"

size="300 150"

alignment="left" />

TextEdit2D fields

These are the fields for TextEdit2D node. Only the node-specific fields are indicated, not fields obtained by inheritance.

Field inheritance: NodeBase > RectBase2D > TextEdit2D

Fields

Type

Use

Default

Description

alignment

senum

Optional

left

Align text horizontally as left, center, right or justify.

caretColor

svec4

Optional

1 1 1 1

Caret color.

caretThickness

sfloat

Optional

1

Caret thickness.

clipboardText

sstring

Optional

Internally calculated

Automatically set to the text that is being passed to the global clipboard.

copySelectedTextToClipboard

sfunction

Optional

 

Upon execution, the selected text is copied to the clipboard.

cutSelectedTextToClipboard

sfunction

Optional

 

Upon execution, the selected text is copied to the clipboard. Finally, the selected text is deleted.

dynamicFontScaling

sbool

Optional

true

Improves the quality of text by applying Dynamic Font Scaling rendering.

enabled

sbool

Optional

false

Enable node for editing.

font

sstring

Optional

Arial,Regular,20

String that takes the font style and size.

fontColor

svec4

Optional

1 1 1 1

Font color when the node is enabled.

fontColorDisabled

sbool

Optional

0.75 0.75 0.75 1

Font color when the node is disabled.

getCaretPosition

sfunction

Optional

SINT getCaretPosition()

Returns current caret position from 0 to text field length.

interlineOffset

sfloat

Optional

0

Distance between the inter lines of text.

margin

sfloat

Optional

4

Margin size applied on left, right and top.

maxChararacters

sint

Optional

0

Maximum characters allowed in the node to be inserted. By default, it is set to 0.

maxScrollOffset

sfloat

Optional

Internally calculated

Automatically updated every time the text is redrawn, and indicates the upper limit of the scrollOffset field.

minimumSize

svec2

Optional

Internally calculated

Internally calculated to maintain the size field above an acceptable value.

password

sbool

Optional

false

To display the text in the password style. By default, it is set to false.

passwordCharacter

sstring

Optional

*

To display the text in particular char so that it is not readable. By default, it is set to *.

pasteTextFromClipboard

sfunction

Optional

 

Upon execution, the text currently on the clipboard is inserted at the caret's current position.

returnInText

sbool

Optional

true

Return on Enter key and bring caret to next line.

returnPressed

sevent

Raise an event when the enter key is pressed.

scrollOffset

sfloat

Optional

Internally calculated

Indicates the current scroll offset. It is automatically updated when the caret goes over the upper or lower boundary of the node, or can be manually set to go to the desired section.

selectedText

sstring

Optional

Internally calculated

Automatically set to the current selected text.

selectionColor

svec4

Optional

0 0 1 0.25

Color of the text area selection.

setCaretPosition

sfunction

Optional

SSTRING getCaretPosition(SINT pos)

Allows you to set the caret position at the specified index position. Returns OK when it succeeds. KO in case of failure (pos is not an integer).

text 

sstring

Optional

Text to be displayed in the node.

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in