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
Trusted Contributor
Posts: 204
Registered: ‎07-03-2011
My Device: Torch
My Carrier: Digicel
Accepted Solution

Panning a normal screen

Hello

 

I'm new to application development; and I mean very new. I'm however trying to do something a bit unorthodox. What I want to do is create a screen three buttons (Top, middle and bottom). Then I want the following action to be performed: When a button is pressed, I want the screen to pan in a particular direction. I need help ASAP, please. And I'm not really a fan for copying and pasting code. So an explanation would be much appreciated. But if not, I'll take what I get.

 

Thanks in advance.

_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Panning a normal screen

Take a look at Manager.setVerticalScroll method. Since any Screen (and MainScreen in particular - are you using that?) is a Manager, the method is available there. To find out the full (not just visible) Screen height, use getVirtualHeight.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Trusted Contributor
Posts: 204
Registered: ‎07-03-2011
My Device: Torch
My Carrier: Digicel

Re: Panning a normal screen

So am I able to control that method by clicking a button? For example can I place that in ItemListener..or is it actionListener..well can I?
_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Panning a normal screen

Buttons are generally associated with FieldChangeListeners (many people skip that and override navigationClick instead), but yes, you can put a call to your screen's setVerticalScroll in fieldChanged method of the FieldChangeListener. Read the documentation for ButtonField - there is a decent example of using FieldChangeListener with it. You can associate the same listener with different buttons and then use fieldChanged's field parameter to distinguish between them.

 

As an aside - create your ButtonFields with NEVER_DIRTY and CONSUME_CLICK style bits - it will save you a lot of headache.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Trusted Contributor
Posts: 204
Registered: ‎07-03-2011
My Device: Torch
My Carrier: Digicel

Re: Panning a normal screen

Thanks much bro!!! May I politely ask what NEVER_DIRTY and CONSUME_CLICK style bits are please?
_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Panning a normal screen

When you create a ButtonField, create it like this:

ButtonField myButton = new ButtonField("button text", ButtonField.CONSUME_CLICK | ButtonField.NEVER_DIRTY);

 

Take a look at the API documentation for ButtonClick.

 

As for why they are important:

CONSUME_CLICK prevents a menu popping up after you click a button. NEVER_DIRTY means the button will not be marked as "dirty" when clicked - important if you are using MainScreen. Read more here:

MainScreen explained

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Trusted Contributor
Posts: 204
Registered: ‎07-03-2011
My Device: Torch
My Carrier: Digicel

Re: Panning a normal screen

You my friend are a Genius. I am having trouble implementing the setVerticalScroll however. Any suggestions?
_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Panning a normal screen

You don't have to implement setVerticalScroll - you use the one that already exists. setVerticalScroll(0) brings you to the top of your VerticalFieldManager, setVerticalScroll(getVirtualHeight() - getVisibleHeight()) brings to the bottom, etc.

 

If you are working only with OS 6.0 and higher, you can use the second form of that method - setVerticalScroll(int position, boolean animate).

 

Make sure your manager (or screen) has VERTICAL_SCROLL style bit set. For example:

VerticalFieldManager myVfm = new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL);

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Trusted Contributor
Posts: 204
Registered: ‎07-03-2011
My Device: Torch
My Carrier: Digicel

Re: Panning a normal screen

So when I use it will Il literally see the screen change orientation?
_______________________________________________________
Never be close-fisted with the knowledge you've received. For if others were the same to you, you would not be painted as the person you are; the flowing definition of you, would be non existent.

You would be meaningless.
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Panning a normal screen

Rather change position Smiley Happy (scroll, pan - however you call it)

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!