Enable pinch gestures

By default, pinch gestures are not enabled on a screen in a BlackBerry® device application. You must set a screen property to enable the generation of pinch gestures on a screen.
  1. Import the required classes and interfaces.
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.ui.input.*;
  2. In your screen object, create an InputSettings object to populate with touch screen properties.
    InputSettings ts = TouchscreenSettings.createEmptySet();
  3. Set the TouchscreenSettings.DETECT_PINCH property to 1.
    ts.set(TouchscreenSettings.DETECT_PINCH, 1);
  4. Invoke Screen.addInputSettings() to add the input settings to the screen.
    addInputSettings(ts);
You can change the value of the TouchscreenSettings.DETECT_PINCH property at any time, not just when you create the screen.

Code sample

This sample demonstrates how to enable pinch gestures in a screen's constructor.

public MyScreen()
{          
   setTitle("Sample Screen");
            
   InputSettings ts = TouchscreenSettings.createEmptySet();
   ts.set(TouchscreenSettings.DETECT_PINCH, 1);
   addInputSettings(ts); 

   ...                
}
Previous topic: Pinch gestures

Was this information helpful? Send us your comments.