HTML5 Element Touch Events

HTML Element

The touchstart, touchend, touchmove, touchenter, touchleave, touchcancel events must be defined on an element.

Learning Resources:

Reference - Touch API BlackBerry browser JavaScript reference guide [BlackBerry Documentation].
Sample - SketchPad Application Example that draws finger sketches on an HTML5 canvas corresponding to touch screen or trackpad movement [BlackBerry Developer Resource Center].

Supported Platform(s)

- BlackBerry OS 6.0+
- BlackBerry PlayBook

View Supported Platform Table

APIOS 5.0OS 6.0OS 7.0PlayBookRipple
ontouchcancel   Y Y Y 
ontouchend   Y Y Y 
ontouchenter   Y Y Y 
ontouchleave   Y Y Y 
ontouchmove   Y Y Y 
ontouchstart   Y Y Y 

Configuration Document Settings

To use all of the API described for this object, you must ensure the following settings are in your configuration document:

This API does not require a <feature> element to be declared in the configuration document of your BlackBerry WebWorks Application.

Permission Elements (PlayBook Only)
This API does not require a <permission> element to be declared in the configuration document of your BlackBerry WebWorks Application.

ontouchcancel


void ontouchcancel(event : TouchEvent)

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook

Description

A user agent must dispatch this event type to indicate when a touch point has been disrupted in an implementation-specific manner, such as a synchronous event or action originating from the UA canceling the touch, or the touch point leaving the document window into a non-document area which is capable of handling user interactions. (e.g. The UA's native user interface, plug-ins) A user agent may also dispatch this event type when the user places more touch points on the touch surface than the device or implementation is configured to store, in which case the earliest Touch object in the TouchList should be removed.



Parameter Type Description
event TouchEvent

ontouchend


void ontouchend(event : TouchEvent)

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook

Description

A user agent must dispatch this event type to indicate when the user removes a touch point from the touch surface, also including cases where the touch point physically leaves the touch surface, such as being dragged off of the screen.

The target of this event must be the same Element that received the touchstart event when this touch point was placed on the surface, even if the touch point has since moved outside the interactive area of the target element.

The touch point or points that were removed must be included in the changedTouches attribute of the TouchEvent, and must not be included in the touches and targetTouches attributes.



Parameter Type Description
event TouchEvent

ontouchenter


void ontouchenter(event : TouchEvent)

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook

Description

A user agent must dispatch this event type to indicate when a touch point moves onto the interactive area defined by a DOM element. Events of this type must not bubble.



Parameter Type Description
event TouchEvent

ontouchleave


void ontouchleave(event : TouchEvent)

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook

Description

A user agent must dispatch this event type to indicate when a touch point moves off the interactive area defined by a DOM element. Events of this type must not bubble.



Parameter Type Description
event TouchEvent

ontouchmove


void ontouchmove(event : TouchEvent)

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook

Description

A user agent must dispatch this event type to indicate when the user moves a touch point along the touch surface.

The target of this event must be the same Element that received the touchstart event when this touch point was placed on the surface, even if the touch point has since moved outside the interactive area of the target element.

If the values of radiusX, radiusY, rotationAngle, or force are known, then the user agent also must dispatch this event type to indicate when any of these attributes of a touch point have changed.

Note that the rate at which the user agent sends touchmove events is implementation-defined, and may depend on hardware capabilities and other implementation details.



Parameter Type Description
event TouchEvent

ontouchstart


void ontouchstart(event : TouchEvent)

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook

Description

A user agent must dispatch this event type to indicate when the user places a touch point on the touch surface.

The target of this event must be an Element.



Parameter Type Description
event TouchEvent

Code Example(s)


<html><head><title>sample</title></head>
  <body>
    <img src="button.png" ontouchstart="alert(event.target)" />
  </body>
</html>
var img = document.createElement('img');
img.ontouchstart=function(e) { 

for(var i = 0; I < e. touches.length; i++)
{
   var touch = touches[i];

   var x = touch.clientX;
   var y = touch.clientY;

   // do something
}
preventMove = function(e) {
   evt.preventDefault();
   window.scroll(0, 0);
   return false;
};
window.document.addEventListener('touchmove', preventMove, false);

Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 30 2012 13:31:17 GMT-0500 (EST)