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
Posts: 406
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

HorizontalField scrolling per item

I have a screen where i am adding a horizontalfield manager which have number of bitmapfields which occupy the entire screen.I want that when i scroll in a touchscreen device,it should only scroll one(next) image and should nt scroll the entire images

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

Re: HorizontalField scrolling per item

Are the BitmapFields focusable?  They will need to be for the scrolling to work on trackpad only devices. 

 

I have never tried it, but have you looked at the HorizontalFieldManager method:

setHorizontalQuantization(int horizontalQuanta)

 

Give that a try, setting the quantization to the width of the screen. 

Developer
Posts: 406
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: HorizontalField scrolling per item

I tried what you suggested,bt no luck :smileysad:

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

Re: HorizontalField scrolling per item

So your BitmapFIelds are focusable?

 

What actually happened?

Developer
Posts: 406
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: HorizontalField scrolling per item

Yes my BitmapField is focusable.When i scroll the first item,the scroll reaches to my last item ie the 3rd one,its not stopping at the second image

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

Re: HorizontalField scrolling per item

Trackpad or swipe?

 

Sorry for slow response, busy elsewhere...

Developer
Posts: 406
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: HorizontalField scrolling per item

Its OK,no issues,swipe actually

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

Re: HorizontalField scrolling per item

Yep you are right the quantization appears to do nothing useful! 

 

Next thing to try. 

 

Detect the swipe in the touchEvent for the Manager.  Detect the direction, and then find out what Field is in focus.  If swipe to the left, set focus on the previous field to the one currently in focus (assuming you are not right at the end).  Other way round for a swipe the other way obviously. 

 

Put the set focus in a

 

UiApplication.getUiApplication.invokeLater(new Runnable() {

public void fun() {

<field>.setFocus();

}

});

 

The reason for the invokeLater is will allow the swipe processing to complete before the focus takes effect - the two could conflict.

 

Let us know how this goes.

Developer
Posts: 406
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: HorizontalField scrolling per item

I am doing something like this on my hfm,but getting nullpointer exception when i swipe 

 

 hfm=new HorizontalFieldManager(HORIZONTAL_SCROLL){
        	protected void sublayout(int maxWidth, int maxHeight) {
        		super.sublayout(maxWidth, maxHeight);
        		setExtent(480, 800);
        	}
        	protected boolean touchEvent(TouchEvent message) {
        		 super.touchEvent(message); 
        		 TouchGesture touchGesture = message.getGesture(); 
        		
        		 if( touchGesture.getSwipeDirection()==TouchGesture.SWIPE_EAST) {
        			 UiApplication.getUiApplication().invokeLater(new Runnable() {
        				 public void run() {
        					// hfm.getFieldWithFocus().setFocus();
        			
        				 }
        				 });
        		 }
				return false;
        	}
        };

 

Developer
Posts: 68
Registered: ‎11-24-2010
My Device: Not Specified

Re: HorizontalField scrolling per item

If you are going to add only bitmap to horizontalFieldManager then go for PictureScrollField. . This can be easier for your code and you no need to worry to handle your code for swipe or trackwheel.