Help Center

Local Navigation

Object: TextEvent

Availability

BlackBerry® Device Software version 4.6 or later

Extends

UIEvent

The TextEvent object extends the UIEvent object and represents an event generated by entering characters using either the BlackBerry device or some other input source, such as a voice command. Unlike with KeyboardEvent objects, TextEvent objects can comprise multiple key presses, essentially creating an event after one or more characters have been entered.

To create an instance of a TextEvent, you must invoke Document.createEvent() with an input parameter of ”TextEvent”.

TextEvent properties

Property name

Type

Description

Status

Availability

data

String

Returns the value of the characters generated by the character device. The value of this property may be a single Unicode character or a sequence of Unicode characters. This property cannot be null or contain an empty string.

read only

4.6 or later

Text event types

Event type

Bubbles

Cancelable

Description

textInput

yes

yes

Occurs when one or more characters have been entered.

This event type includes the following context information:

TextEvent.data, UIEvent.view

TextEvent methods

Method name

Description

Availability

initTextEvent()

Initializes the value of a TextEvent.

4.6 or later

initTextEventNS()

Initializes the value of a TextEvent with the given namespace URI.

4.6 or later

Method: TextEvent.initTextEvent()

The initTextEvent() method initializes the value of a TextEvent created by Document.createEvent().

Syntax

TextEvent.initTextEvent( typeArg, canBubbleArg, cancelableArg, viewArg, dataArg )

Parameters

Parameter

Type

Description

typeArg

String

Specifies the event type.

canBubbleArg

boolean

When true, this parameter indicates that the event can bubble.

cancelableArg

boolean

When true, this parameter indicates that the event can be cancelled.

viewArg

AbstractView

Specifies the window or frame that is generating the event.

dataArg

String

Specifies the characters generated by the input device. This parameter sets the value of TextEvent.data.

Return values

None.

Exceptions

None.

Method: TextEvent.initTextEventNS()

The initTextEventNS() method initializes the value of a TextEvent created by Document.createEvent() with the given namespace URI.

Syntax

TextEvent.initTextEventNS( namespaceURI, typeArg, canBubbleArg, cancelableArg, viewArg, dataArg )

Parameters

Parameter

Type

Description

namespaceURI

String

Specifies the namespace URI associated with this event, or null if no namespace exists.

typeArg

String

Specifies the event type.

canBubbleArg

boolean

When true, this parameter indicates that the event can bubble.

cancelableArg

boolean

When true, this parameter indicates that the event can be cancelled.

viewArg

AbstractView

Specifies the window or frame that is generating the event.

dataArg

String

Specifies the characters generated by the input device. This parameter sets the value of TextEvent.data.

Return values

None.

Exceptions

None.

Previous topic: Method: Text.splitText()

Was this information helpful? Send us your comments.