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
Berrysoft
Posts: 143
Registered: ‎07-14-2008
My Device: Not Specified
Accepted Solution

How to - scroll one screen?

I want to be able to scroll down "one screen" when the user presses SPACE.

 

How do I do this?  I can go to the top or bottom, but not a screen at a time.

 

 

protected boolean keyChar( char c, int status, int time ) { boolean consumed = false; switch( c ) { case Characters.SPACE: break; case 't': setVerticalScroll( Manager.TOPMOST ); break; case 'b': setVerticalScroll( Manager.BOTTOMMOST ); break; } return consumed; }

 

 

 

BlackBerry Development Advisor
MSohm
Posts: 14,757
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: How to - scroll one screen?

You can use the same method to accomplish this by passing in the location of the screen you wish to scroll to.  You can use the Display class to get the height of the entire screen that can be used to scroll down one screen at a time.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Berrysoft
Posts: 143
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to - scroll one screen?

I'm not following you.

 

I know the screen size, that's not the problem.  The problem is what method can "scroll" by a specified amount????

 

Patrick

 

Developer
Berrysoft
Posts: 143
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to - scroll one screen?

Think I found what I need:

 

public final boolean scroll(int direction)
Scrolls the focus in specified direction.

The parameter passed to this method indicates the direction and amount of movement required.

To control vertical movement use Manager.UPWARD and Manager.DOWNWARD to move the focus one screen up or down; use Manager.TOPMOST and Manager.BOTTOMMOST to move the focus all the way to the top edge or bottom edge of the manager's region.

 

Developer
Berrysoft
Posts: 143
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to - scroll one screen?

So, when I use this code now:

 

 

protected boolean keyChar( char c, int status, int time ) { boolean consumed = false; switch( c ) { case Characters.SPACE: scroll( Screen.DOWNWARD ); break; case 't': setVerticalScroll( Screen.TOPMOST ); break; case 'b': setVerticalScroll( Screen.BOTTOMMOST ); break; } return consumed; }

 

pressing SPACE does indeed scroll down one screen-full.  But, pressing 't' or 'b' does nothing.  Why is this not working?

 

Patrick

 

 

 

Developer
Berrysoft
Posts: 143
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to - scroll one screen?

In case others are trying to figure this out, here was the solution:

 

 

protected boolean keyChar( char c, int status, int time ) { switch( c ) { case Characters.SPACE: if ((status & KeypadListener.STATUS_SHIFT) == 0) { scroll( Manager.DOWNWARD ); } else { scroll( Manager.UPWARD ); } return true; case 't': scroll( Manager.TOPMOST ); return true; case 'b': scroll( Manager.BOTTOMMOST ); return true; } return super.keyChar(c, status, time); }

 

 

 

Developer
kungfucop
Posts: 57
Registered: ‎05-25-2009
My Device: Not Specified

Re: How to - scroll one screen?

it is quite weired that this piece of code works well on bold curve, but not those 8820 and 8830. When we let it to go to bottom, it only scrool down one screen, and never does it again.