Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
amahfouz
Posts: 29
Registered: ‎06-23-2009
My Device: Not Specified

Default handling of MOVE gesture and inertial scrolling

The default handling of a “MOVE” touch gesture is pretty bad. I have a scrollable Manager on a screen. When you move your finger up to scroll the Manager, it partially scrolls but then stops and the screen starts scrolling. Keep doing that and the Manager will scroll off the top of the screen before it gets scrolled all the way! Pretty bad. Even worse, move your finger up, the manager scrolls up, then stop moving, pause for a couple of seconds, lift your finger, and the screen continues scrolling up!

 

I found the setScrollingIntertial(false) on the Manager and the screen. Now I can scroll the Manager without the screen moving. However, when the manager is scrolled all the way up moving the finger up on the area of the Manager does not scroll the screen.

 

Before going further and trying to override touchEvent() method of the Manager, its enclosing Manager, and the screen, does anyone have a recommendation to achieve the desired effect?

 

(The desired effect is to have the finger move scroll the Manager until the Manager is scrolled all the way then the move will scroll the screen.)

Please use plain text.
Developer
amahfouz
Posts: 29
Registered: ‎06-23-2009
My Device: Not Specified

Re: Default handling of MOVE gesture and inertial scrolling

Here is sample code to illustrate the problem. Try it as listed below and also try it will all three appearances of setScrollingInertial(false) commented out. Behavior is unacceptable in both cases.  
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.FullScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

public final class TestApp extends UiApplication {

    public static void main(String[] args) {
        UiApplication app = new TestApp();
        final WidgetScreen screen = new WidgetScreen();
        screen.add(new LabelField("Intertial Scrolling Test"));
        
        for (int i = 0; i < 4; i++) {
            screen.add
                  (new ButtonField("First Button Set " + i));
        }
        
        screen.add(new TestManager());
        
        for (int i = 0; i < 12; i++) {
            screen.add
                    (new ButtonField("Second Button Set " + i));
        }
        
        app.pushScreen(screen);
        app.enterEventDispatcher();
    }
}

final class TestManager extends Manager {

    protected TestManager() {
        super(VERTICAL_SCROLL);
        
        addButtons();
        
        setScrollingInertial(false);
    }
    
    protected void sublayout(int width, int height) {
        int numFields = getFieldCount();
        int y = 0;
        for (int i = 0; i < numFields; i++) {
            Field field = getField(i);
            layoutChild(field, width, 40);
            setPositionChild(field, 0, y);
            y += field.getHeight();
        }
        setExtent(width, y / 3);
        setVirtualExtent(width, y);
    }
    
    public void addButtons() {
        for (int i = 0; i < 20; i++) {
            add(new ButtonField("B " + i));
        }
    }
}

final class MainScreenManager extends VerticalFieldManager {

    public MainScreenManager() {
        super(Field.USE_ALL_HEIGHT | VERTICAL_SCROLL);
        
        setScrollingInertial(false);
    }
}

final class WidgetScreen extends FullScreen {
    
    public WidgetScreen() {
        super(new MainScreenManager(), 
              Screen.DEFAULT_CLOSE | Screen.DEFAULT_MENU);
        
        setScrollingInertial(false);
    }
}
Please use plain text.