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.
-
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.*;
-
In your screen object, create an
InputSettings object to populate with touch screen
properties.
InputSettings ts = TouchscreenSettings.createEmptySet();
-
Set the
TouchscreenSettings.DETECT_PINCH property to
1.
ts.set(TouchscreenSettings.DETECT_PINCH, 1);
-
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);
...
}
Was this information helpful? Send us your comments.