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
avinash_kumar_ispg_in
Posts: 172
Registered: ‎01-02-2012
My Device: 8520 curve

How to control horizontal scroll

Hi every one 

  I have a list of images with some text and button ,i am addint it in to a single vertical manager and that vertical manager i am adding in to horizontal manager with horizontal scroll feature. it is working fine with roll over button while i am scrolling it Horizontaly.

 

 But my problem is with touch screen device,  if i am scrolling a little left side it by touching it should apear whole next right side list view,But it is not happening.it is appearing how much i am scrolling it by touching.

 

How to make it scroll fully like roll over button.

 

Thanks.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to control horizontal scroll

I assume when you say rollover button, you are talking about the trackpad.

 

The trackpad works how you want it to because it moves focus.  Swiping does not change focus.  So you need to find some mechanism to simulate this.  This is not easy if you want the user to be able to swipe multiple items in the HorizontalFieldManager.  It is also complicated by the fact that the HFM might not have focus anyway.

 

For now assume you want to move one Field at a time.

 

Implement a scroll change listener.  When this is invoked, check to see if the HFM is in focus.  If not,then find out which field is currently being scrolled using <manager>.getFieldAtLocation().  If it is in focus, find out which field has focus using getFieldWithFocusIndex.  Them wait for the next scroll indication.  If the scrolling is moving to the left, then set focus on the Field before the one you calculate a above,  If to the right, then the one after.  Now logically disable your scroll change listener for a second to let things settle down.  Then re-enable and go through the checks I described above with the next scroll change.

 

This is not a full description of the requirements, but is intended to be enough to get you going.  You will find you need to do some thinking yourself to figure out what is actually going on.  Then you might want to change this processing to match what you really want.  But hopefully this will give you the background you need.