AnnotationText
- Last UpdatedSep 26, 2025
- 4 minute read
The AnnotationText node allows you to place a rect and add the text in it. It inherits from AnnotationBase and can be moved and stretched.
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 |
|
|
|
|
|
|
Handles position and behavior
The AnnotationText has one handle at the right bottom, which can be used to resize the node.
Differently from all other annotation nodes, it's not only the size that changes, the font changes too. This is achieved by driving the fontScale value.
The same result can be achieved in three different ways:
-
Moving the handle.
-
Directly setting the fontScale.
-
Using setFontScaleFromWidth. The sfunction calculates the proper fontScale value to meet the requested width.
The minimumFontScale field is used to define the lower limit for scaling and can be adjusted to prevent the fontScale from producing content that is too small and unreadable. The limit is applied consistently to all the three font scaling methods.
Customization
Additionally to all the customization fields derived from AnnotationBase, the AnnotationText has a few more fields:
-
font—Manages the desired font family, dimension, and effect (such as bold or italic).
-
backColor and editBackColor—AnnotationText has a background and these fields set the color when editing and when not.
-
fontColor and editFontColor—Defines the text color when editing and when not.
-
caretThickness—Customizes caret aspect.
-
margin and interlineOffset—Adds additional space between the text and the borders or between text lines.

Selection and editing
By default, node selection and editing state are coupled. However, the node offers a few specific fields to decouple standard behavior:
-
editOnSelection—Automatically couples edit state with selection state.
-
editEnabled—Enables editing when needed without setting the select state.
Caret management
AnnotationText supports caret visualization and movements. Supported CARET actions are:
-
Arrows movements
-
Home and End
-
PageUp and PageDown
In addition to this, click in any text point to directly position the caret where you like.
AnnotationText fields
These are the fields for AnnotationText node. Only the node-specific fields are indicated, not fields obtained by inheritance.
Field inheritance: NodeBase > RectBase2D > AnnotationBase > AnnotationText
|
Fields |
Type |
Use |
Default |
Description |
|---|---|---|---|---|
|
backColor |
svec4 |
Optional |
0.8 0.407843 0.407843 0.407843 |
Background color when the node is not selected for editing. |
|
caretThickness |
sfloat |
Optional |
1 |
Caret thickness. |
|
dynamicFontScaling |
sbool |
Optional |
true |
Improves the quality of text by applying Dynamic Font Scaling rendering. |
|
editBackColor |
svec4 |
Optional |
0.8 1 1 1 |
Background color when the node is selected for editing. |
|
editEnable |
sbool |
Optional |
false |
Enable nodes for editing. By default, it is driven by selected state. |
|
editFontColor |
svec3 |
Optional |
0 0 0 |
Font color while writing the text. |
|
editOnSelection |
sbool |
Optional |
true |
To insert the text after clicking on the node, user can direct start writing text on clicking. By default, it is enabled. |
|
font |
sstring |
Optional |
Arial,Regular,20 |
String that takes the font style and size. |
|
fontColor |
svec3 |
Optional |
1 1 1 |
Font color when the node is not selected for editing. |
|
fontScale |
sfloat |
Internally calculated |
1 |
Scale factor for font size, when the size of the node is changed. |
|
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. |
|
maxChars |
sint |
Optional |
0 |
Maximum characters allowed in the node to be inserted. By default, it is set to 0. |
|
minimumFontScale |
sint |
Optional |
0.2 |
Defines the lower limit for the fontScale. The value must be included between 0.001 and 1. |
|
password |
sbool |
Optional |
false |
To display the text in the password style. By default, it is set to false. |
|
passwordChar |
sstring |
Optional |
* |
To display the text in particular char so that it is not readable. By default, it is set to *. |
|
returnInText |
sbool |
Optional |
true |
Return on Enter key and bring caret to next line. |
|
returnPressed |
sstring |
Raise an event when the enter key is pressed. |
||
|
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). |
|
|
setFontScaleFromWidth |
sfunction |
Optional |
SSTRING setFontScaleFromWidth.execute(RECTWIDTH) Sets the rect width to the desired value, recalculate the height to maintain the original ratio and modify the fontScale accordingly. For example, setFontScaleFromWidth.execute (100). Returns OK. |
|
|
text |
sstring |
Optional |
Text to be displayed in the node. |