Using gestures

The Gesture API allows MIDlets to receive notifications when the user interacts with Canvas or CustomItem elements. The API registers touch interaction as a series of gesture events.

You can combine the Gesture API with the Frame Animator API to create linear drag and kinetic scroll animations. You can also use gesture events with multipoint touch events to implement more complex touch functionality.

API contents

The Gesture API consists of the following classes and interfaces (packaged as part of the Nokia UI API):

  • GestureEvent

    Use the GestureEvent interface to retrieve information about a gesture event. A GestureEvent object returned by the platform represents a single gesture event of a given type.

  • GestureInteractiveZone

    Use the GestureInteractiveZone class to define the touchable screen area and which types of gesture events are received from this area.

  • GestureListener

    Use the GestureListener interface to implement a listener for receiving a notification whenever a gesture event occurs.

  • GestureRegistrationManager

    Use the GestureRegistrationManager class to manage GestureInteractiveZones and GestureListeners.

The Gesture API is supported since Nokia UI API 1.1b.

Device compatibility

The Gesture API is supported since Series 40 6th Edition Feature Pack 1.

Implementing touch functionality

To implement touch functionality in your MIDlet:

  1. Set the MIDlet to receive gesture events

  2. Define the handling of gesture events in the MIDlet

For more information about the Gesture API classes and methods, see the Gesture API reference.

Basic touch actions

From Series 40 6th Edition Feature Pack 1 and Nokia Asha software platform devices, the Series 40 and Nokia Asha software platform devices support touch interaction on mobile devices with a touch screen. The touch screen is sensitive to the user's finger and device stylus, thus replacing or complementing the physical keys of the device as the main means of interaction. The touch UI allows the user to directly manipulate objects on the screen, enabling a more natural interaction with the device. Touch devices support a variety of design possibilities that cannot be implemented in traditional key-based mobile applications. If a device has a physical keypad and a touch screen, both can be used to interact with applications. To find out which devices have a touch screen, see Nokia Developer device specifications and filter devices based on "Touch Screen".

Table: Basic touch actions

Action

Description

Example

Touch events

Touch

The user presses the finger or stylus against the screen.

 

touch down

Release

The user lifts the pressed finger or stylus from the screen.

 

touch release

Tap

The user presses the finger or stylus against the screen for a brief moment and then lifts it from the screen.

Tap:

touch down + touch release ("touch down and release")

Double Tap

The user presses the finger or stylus against the screen and then lifts it from the screen, twice in quick succession.

Double Tap:

 

Long tap

The user presses the finger or stylus against the screen and holds it there for a set amount of time. The time-out value depends on the platform.

Depending on the object that is long-tapped, this action can also constitute a key repeat.

Long tap:

touch down and hold

Drag

Drag and drop

The user presses the finger or stylus against the screen and then slides it over the screen.

This action can be used for scrolling or swiping content, including the whole screen, and dragging and dropping objects. In drag and drop, the user "grabs" an object on the screen by touching it, drags it to a different location on the screen, and then "drops" it by releasing touch.

Note: High-level UI elements do not support drag and drop. You must implement drag and drop separately by using low-level UI elements.

Drag:

Drag and drop:

touch down + drag

touch down + drag + touch down ("stop") + touch release

Flick

The user presses the finger or stylus against the screen, slides it over the screen, and then quickly lifts it from the screen in mid-slide. The user can also slide the finger or stylus off the screen. The content continues scrolling with the appropriate momentum before finally stopping.

Flick:

touch down + drag + touch release while dragging

Pinch

Pinch open

Pinch close

To pinch open, the user presses the thumb and a finger (or two fingers) close together against the screen, moves them apart without lifting them from the screen, stops, and releases touch.

To pinch close, the user presses the thumb and a finger (or two fingers) a short distance apart against the screen, moves them towards each other without lifting them from the screen, stops, and releases touch.

Pinch actions can be used, for example, for zooming in and out of content such as pictures and text.

Note: Pinch is supported from Java Runtime 2.0.0 for Series 40. Earlier Series 40 and Nokia Asha touch devices do not support pinch.

Pinch open:

Pinch close:

2 x touch down + 2 x drag ("pinch") + 2 x touch down ("stop") + 2 x touch release