Skip to main content

TextInputSystem

Class

Provides access to the device's input system.

  • 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.

Provides access to the device's input system. Accessible through global.textInputSystem.

Index

Example

var options = new TextInputSystem.KeyboardOptions();
options.enablePreview = false;
options.keyboardType = TextInputSystem.KeyboardType.Text;
options.returnKeyType = TextInputSystem.ReturnKeyType.Done;

global.textInputSystem.requestKeyboard(options);

Extends

Methods

dismissKeyboard()

dismissKeyboard(): void

Requests the client to hide the keyboard and clear any existing text in the inivisible text view.

Returns

void

Since

Lens Scripting Version 165

Example

var options = new TextInputSystem.KeyboardOptions();

global.textInputSystem.requestKeyboard(options);
global.textInputSystem.dismissKeyboard();

getTypeName()

static getTypeName(): TypeName<TextInputSystem>

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<TextInputSystem>

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame


requestKeyboard()

requestKeyboard(options): void

Requests the client to pop up the keyboard with specific type and return key type, fill the inivisible text view with the initial text, and set the selected text range. When user starts editing the text, the new text string and the new selected range are returned to the lens by invoking the onTextChanged function.

Parameters

ParameterType
optionsKeyboardOptions

Returns

void

Since

Lens Scripting Version 165


setEditingPosition()

setEditingPosition(position): void

Requests the client to set the editing ("cursor") position on the invisible text view.

Parameters

ParameterType
positionnumber

Returns

void

Since

Lens Scripting Version 165

Example

var options = new TextInputSystem.KeyboardOptions();

global.textInputSystem.requestKeyboard(options);

global.textInputSystem.setEditingPosition(10);

setSelectedTextRange()

setSelectedTextRange(range): void

Requests the client to set the selected text range on the invisible text view.

Parameters

ParameterType
rangevec2

Returns

void

Since

Lens Scripting Version 165

Example

var options = new TextInputSystem.KeyboardOptions();

global.textInputSystem.requestKeyboard(options);

global.textInputSystem.setSelectedTextRange(new glm.vec2(0, 10));

updateText()

updateText(update): void

SPECS

Requests the client to update the text and selection on the invisible text view. Only has effect when the keyboard is shown (after requestKeyboard). Supported on platforms that implement the text input session (e.g. SnapOS).

Parameters

ParameterType
updateTextUpdate

Returns

void

Since

Lens Scripting Version 365

Example

var options = new TextInputSystem.KeyboardOptions();

global.textInputSystem.requestKeyboard(options);

var update = new TextInputSystem.TextUpdate();
update.text = "Hello, world!";
update.selectionStart = 0;
update.selectionEnd = 10;

global.textInputSystem.updateText(update);

Nested types

Enumerations

EnumerationDescription
KeyboardKindThe kind of keyboard currently serving the text input session. Delivered through onKeyboardKindChanged.
KeyboardTypeThe different input style of keyboard input.
ReturnKeyTypeThe return key style of keyboard input.
TextFieldActionEditor action for the text field (e.g. when user presses action key on keyboard).

Classes

ClassDescription
KeyboardOptionsThe settings used for how the input keyboard should work.
TextUpdateText update from the input method (text and selection range).