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
New Contributor
Posts: 4
Registered: ‎02-17-2010
My Device: Not Specified
Accepted Solution

5.0 Inertial scrolling issue

Hi, I am trying to figure out why this bug seems to be happening in one of my programs on a Storm 2. First some simplified code to reproduce the problem.

 

 

public class MyScreen extends FullScreen {

    public MyScreen() {
        this(new VerticalFieldManager(VERTICAL_SCROLL | VERTICAL_SCROLLBAR));
    }

    protected MyScreen(VerticalFieldManager manager) {
        super(manager, 0);

        add(new RichTextField("First item"));
        add(new RichTextField("item 2"));
        add(new RichTextField("item 3"));
        add(new RichTextField("item 4"));
        add(new RichTextField("item 5"));
        add(new RichTextField("item 6"));
        add(new RichTextField("item 7"));
        add(new RichTextField("item 8"));
        add(new RichTextField("item 9"));
        add(new RichTextField("item 10"));
        add(new RichTextField("item 11"));
        add(new RichTextField("item 12"));
        add(new RichTextField("item 13"));
        add(new RichTextField("item 14"));
        add(new RichTextField("item 15"));
        add(new RichTextField("item 16"));
        add(new RichTextField("item 17"));
        add(new RichTextField("item 18"));
        add(new RichTextField("item 19"));
        add(new RichTextField("last item"));
    }

    protected void paintBackground(Graphics g) {
        g.drawBitmap(0, 0, 480, 360, Bitmap.getBitmapResource("backgroundImage.png"), 0, 0); 
    }
}

 

 

The new Inertial scrolling seems to be causing my background to scroll when I am intending for it to stay in place. This ends up leaving pieces of the background in places it shouldn't be since I think the VerticalFieldManager is efficiently drawing only the parts that need to be redrawn. I have also tried painting the background in paint and then calling paintChild(g, manager), but this has the same problem.

 

Is there a way to set up the Manager so that it knows not to scroll the background as well?

 

Thanks,

David

Developer
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: 5.0 Inertial scrolling issue

Try adding the following before your g.drawBitmap line and see if it works:

 

 

super.paintBackground( g );

 

 

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
New Contributor
Posts: 4
Registered: ‎02-17-2010
My Device: Not Specified

Re: 5.0 Inertial scrolling issue

Thanks for the reply, I gave that a try but no luck. I did find a way around this issue though. I can use the following to set the background.

 

 

setBackground(BackgroundFactory.createBitmapBackground(backgroundBitmap));

 

Then I no longer have my paintBackground method. This was introduced in JDE 4.6. Is this what most people are doing? The code that I am working on was originally designed back in the day for OS 4.0, so is my problem that the code is behind the times?

 

Highlighted
Developer
Posts: 157
Registered: ‎02-18-2009
My Device: Not Specified

Re: 5.0 Inertial scrolling issue

I think I have a similar problem. In one of my screens I use some RichtTextFields at the top of the screen and the rest of the screen if taken by a BrowserField. If the BrowserField is longer than the screen the top is sometimes garbled. The workaround which works for me is to add a ScollListener in the constructor of the screen which invalidates the screen when the user scrolls:

 

 

getMainManager().setScrollListener(new ScrollChangeListener() {
public void scrollChanged(Manager manager, int i, int j) {
invalidate();
}
});

Perhaps this works for you as well?

 

New Contributor
Posts: 4
Registered: ‎02-17-2010
My Device: Not Specified

Re: 5.0 Inertial scrolling issue

I swear I had tried that before, but I guess not because that worked great. It has the added advantage of working on pre 4.6 devices. Thanks a lot!