Adding multipoint touch

The Multipoint Touch API allows MIDlets to handle multipoint touch interaction on Canvas and Canvas-based elements, such as GameCanvas and FullCanvas, and on CustomItem.

For more information, see Implementing multipoint touch functionality.

Also refer the Paint example to learn how multipoint touch interaction is added.

class myClass extends GameCanvas implements MultipointTouchListener {

MultipointTouch multipointTouch;
public myClass () {



// Code snippet to check Multipoint Touch API support
if (System.getProperty("com.nokia.mid.ui.multipointtouch.version") != null) {
			// API is supported: Can implement multipoint touch functionality
			System.out.println("Multitouch supported");
} else {
			// API is not supported: Cannot implement multipoint touch functionality
			System.out.println("Multitouch not supported");
}
			
multipointTouch = MultipointTouch.getInstance();
			
multipointTouch.addMultipointTouchListener(this);
}

/*
The MultipointTouchListener interface defines the pointersChanged method, which is     called every time the platform triggers a multipoint touch event.
	*/
public void pointersChanged(int[] pointerIds) {
		int pointerId;
		int x;
		int y;
		int state;
		
		// Loop through the changed touch points
		for(int i=0; i < pointerIds.length; i++) {
		        // Get the touch point ID
		        pointerId = pointerIds[i];

		        // Get the touch point state
		        state = MultipointTouch.getState(pointerId);

		        // Get the touch point x and y coordinates
		        x = MultipointTouch.getX(pointerId);
		        y = MultipointTouch.getY(pointerId);
			      
		        // Handle the UI update based on the touch point state,
		        // ID, and coordinates
		        switch(state) {
			            case MultipointTouch.POINTER_PRESSED:
			                // A new finger was pressed against the screen
				         break;
			            case MultipointTouch.POINTER_DRAGGED:
			                // A pressed finger was dragged over the screen
			                break;
			            case MultipointTouch.POINTER_RELEASED:
			                // A pressed finger was lifted from the screen
			                break;
			            default:
			                break;
}
			        
		}
}
			
}