Touch API
Object: TouchEvent
The TouchEvent object extends the UIEvent object and represents an event generated when the user touches the surface of a touch-sensitive screen.
By default, touch events from the user are consumed by the BlackBerry Browser UI. The browser uses these events in order to provide improvements in usability. For example, the user must use their finger to scroll through the content, and can double-tap to zoom in to a content block. To prevent these events from being consumed by the UI, you can use the touch-event-mode meta tag.
With this meta tag, you can disable these UI features for a web page, so that the browser passes the entire array of events and gestures to the web page unprocessed. With access to raw touch events, you can, for example, track both the direction and distance of a swipe event, and respond differently based on the swipe direction or distance.
The touch-event-mode meta tag is added to the <head> section of a page as part of a <meta> element. For more information see touch-event-mode.
Touch event types
|
Event type |
Bubbles |
Cancelable |
Description |
|---|---|---|---|
|
touchstart |
yes |
yes |
Occurs when the user places a touch point on a touch-sensitive screen. |
|
touchend |
yes |
yes |
Occurs when the user removes a touch point from a touch-sensitive screen. |
|
touchmove |
yes |
yes |
Occurs when the user moves a touch point along the surface of a touch-sensitive screen, or if there is a change in one or more of radiusX, radiusY, rotation, or force. |
|
touchenter |
no |
yes |
Occurs when the user moves a touch point onto an interactive area defined by a DOM element. |
|
touchleave |
no |
yes |
Occurs when the user moves a touch point off of an interactive area defined by a DOM element. |
|
touchcancel |
yes |
yes |
Occurs when the user performs some action that disrupts the sequence of touch points. |
TouchEvent properties
|
Property name |
Type |
Description |
Status |
Support level |
||
|---|---|---|---|---|---|---|
|
changedTouches |
Specifies a TouchList containing a list of TouchPoint objects that represent every point of contact that contributed to the touch event. |
read only |
7.0+ |
1.0+ |
||
|
targetTouches |
Specifies a TouchList containing a list of TouchPoint objects that represent every point of contact currently touching the screen surface that started on the same target. |
read only |
7.0+ |
1.0+ |
||
|
touches |
Specifies a TouchList containing a list of TouchPoint objects that represent every point of contact currently touching the screen surface. |
read only |
7.0+ |
1.0+ |
TouchEvent methods
Object: TouchList
The TouchList object is an array that contains an ordered collection of individual points of contact (represented by TouchPoint objects) for a touch event.
TouchList properties
|
Property name |
Type |
Description |
Status |
Support level |
||
|---|---|---|---|---|---|---|
|
length |
unsigned long |
Returns the number of TouchPoints in the list. |
read only |
7.0+ |
1.0+ |
TouchList methods
|
Method name |
Description |
Support level |
||
|---|---|---|---|---|
|
identifiedPoint() |
Returns the first TouchPoint with the specified identifier in the collection. |
7.0+ |
1.0+ |
|
|
item() |
Returns the TouchPoint at the specified index in the collection. |
7.0+ |
1.0+ |