TextEdit

Description

The TextEdit component creates an editable text box for text entry on a single or multiple lines. The last line includes a white underline to clearly delineate that the text box is editable. Include a UTF-8 compatible font in your project if you expect characters outside of the ISO Latin-1 character set.

Example

<TextEdit
charSpacing={0.02}
height={0.08}
lineSpacing={0.3}
localPosition={[-0.9, 0.5, 0]}
padding={[0.5, 0.3, 0.5, 0.3]}
text="Edit Me"
textAlignment="center"
textSize={0.03}
width={0.4}
/>

Common Events

Common Properties

Create Properties

NameTypeDefault ValueDescription
textstringn/aThe initial UTF-8 encoded text in the text box.
widthnumbern/aThe width of the text edit area.
heightnumbern/aThe height of the text edit area.

Aditional (optional) parameters for create step.

NameTypeDefault ValueDescription
fontDescriptionobjectn/aA 2D font that is a font rendered onto a planar image (whatever the format), as opposed to a 3D model of the glyphs or other graphical representation.
filePathstringn/aThe font file from which the glyphs are loaded. By default this is assumed to be a relative path from the executable file.
absolutePathbooleanfalseFlags that the filePath is an absolute path name, instead of a relative path.

fontDescription

{
advanceDirection: <string>,
flowDirection: <string>,
tileSize: <number>,
quality: <string>,
minAlpha: <number>,
}

AdvanceDirection options: AdvanceDirection

FlowDirection options: FlowDirection

Quality options: Quality

Element Properties

NameTypeDescription
charLimitnumberSets the maximum number of characters allowed in the text box.
charSpacingnumberSets the additional character spacing that is applied between characters. Note that 0 is the default spacing.
cursorEdgeScrollModestringSets the cursor edge scroll mode for this text box.
stylestringSets the style of the Magic Leap font.
weightstringSets he weight (i.e., thickness) of the Magic Leap font.
hintstringSets the UTF-8 encoded text for hint text.
hintColorvec4Sets the text color of the hint.
lineSpacingnumberSets the line spacing to adjust the distance between lines of text; e.g., use 1 for single-spaced text, 2 for double-spaced text. The default is 1.0.
multilinebooleanSets whether the text box is in multiline mode or not. The default is single line.
passwordbooleanSets whether the text box is in password mode or not.
scrollBarVisibilitystringCreates and shows the scrollbar in the vertical direction. If a scrollbar already exists, only its visibility is affected. This function also attaches the scrollbar to the ScrollView that manages it.
scrollingbooleanSets whether scrolling is enabled or not.
scrollSpeednumberSets the scroll speed in scene units per second.
scrollValuenumberManually scrolls the textEdit content position using a normalized value between 0 and 1.
selectedBeginnumberThe first index for text selection.
selectedEndnumberThe last index for text selection.
textstringSets the UTF-8 encoded text.
textAlignmentstringAligns the text to the left, center, or right or justifies it.
textColorvec4Sets the RGBA color of the rendered text.
textEntrystringSets the current text entry mode of the text box.
textPaddingvec4Sets the padding around the text within the text edit area. This defaults to half the text size unless explicitly set. The padding order is: top, right, bottom, left.
textSizenumberSets the text render size height in scene units.
fontParamsobjectSets the font parameters, including syle, weight, pixel size, and tracking. This uses one of the default sets of Magic Leap font resources that support style and weight.

fontParameters

{
style: string,
weight: string,
fontSize: number,
tracking: number,
allCaps: boolean
}

style options: FontStyle

weight options: FontWeight

textAlignment options: HorizontalTextAlignment

cursorEdgeScrollMode options: CursorEdgeScrollMode

scrollBarVisibility options: ScrollBarVisibility

textEntry options: TextEntryMode