Skip to main content

CursorPosition

Class

The position of a text cursor for a given character index, returned by Text.getCursorPositions and Text3D.getCursorPositions.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Since Lens Scripting v324

Index

Example

//@input Component.Text textComponent
var cursors = script.textComponent.getCursorPositions();
cursors.forEach(function (cursor) {
print("Character " + cursor.index + " cursor at " + cursor.position);
});

Properties

index

readonly index: number

Character index in the current text that this cursor precedes.

Since

Lens Scripting Version 324


position

readonly position: vec2

Position of the cursor, in the same coordinate space as the Text component's local layout.

Since

Lens Scripting Version 324

Methods

getTypeName()

static getTypeName(): TypeName<CursorPosition>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<CursorPosition>

Since

Lens Scripting Version 324