Enable swipe gestures that users make on the trackpad

By default, swipe gestures that BlackBerry® device users make on the trackpad are not enabled on a screen. You must set a navigation property to enable the generation of trackpad swipe 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 navigation properties.
    InputSettings nd = NavigationDeviceSettings.createEmptySet();
  3. Set the NavigationDeviceSettings.DETECT_SWIPE property to 1.
    nd.set(NavigationDeviceSettings.DETECT_SWIPE, 1);
  4. Invoke Screen.addInputSettings() to add the input settings to the screen.
    addInputSettings(nd);
You can change the value of the NavigationDeviceSettings.DETECT_SWIPE property at any time, not just when you create the screen.

Code sample

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

public MyScreen()
{          
   setTitle("Sample Screen");
            
   InputSettings nd = NavigationDeviceSettings.createEmptySet();
   nd.set(NavigationDeviceSettings.DETECT_SWIPE, 1);
   addInputSettings(nd); 

   ...                
}
Next topic: Event injection

Was this information helpful? Send us your comments.