Blackberry: overriding touch event for manager overrides all other fields

Blackberry: overriding touch event for manager overrides all other fields,blackberry,Blackberry,I have the following code, which uses gestures to perform scrolling on my hfm, but overriding this hfm, essentially overrides all the fields on the screen, making them useless. How is that possible, I thought this specific touchEvent belonged to the hfm? How do I get around this and just disable the touch scrolling for the hfm? gallery = new CustomHFM(){ protected void sublayout(int maxWidth, int maxHeight){ super.sublayout(maxWidth, 200); setExten

I have the following code, which uses gestures to perform scrolling on my hfm, but overriding this hfm, essentially overrides all the fields on the screen, making them useless. How is that possible, I thought this specific touchEvent belonged to the hfm? How do I get around this and just disable the touch scrolling for the hfm?

gallery = new CustomHFM(){



            protected void sublayout(int maxWidth, int maxHeight){
                super.sublayout(maxWidth, 200);
                setExtent(maxWidth,200);
            }


            protected boolean touchEvent(TouchEvent message){

                int eventCode = message.getEvent();

                if(eventCode == TouchEvent.GESTURE){
                    System.out.println("SWIPE GESTURE");
                    TouchGesture g = message.getGesture();
                    int gesturecode = g.getEvent();
                    int direction = g.getSwipeDirection();

                        //gallery.setHorizontalScroll(page_two, true);
                    if(direction == TouchGesture.SWIPE_WEST)
                        slideNext();

                    if(direction == TouchGesture.SWIPE_EAST)
                        slidePrev();

                    pressed = true;
                }

                if(eventCode == TouchEvent.UP){
                pressed = false;

                //slide();
                }


                return true;
            }
        };

#1

You should return true from the touchEvent-method only when the manager consumes the event, and it shouldn't propagate any further down the hierarchy. Probably you should call super.touchEvent also, before handling it, but I'm not sure on this.


#2

adding return true under SWIPE_WEST and EAST, and having super.touchEvent(message) doesn't work either

#3

How do you know when the manager consumes the event? As a temporary fix I isolated return true only when the x y pos is where the manager is, however this approach won't work if the screen is dynamic and the manager is in a scroll and different position

#4

That's up to you to decide. Usually, if you take action due to some event, you don't want other parts of the UI to respond to that event, so you tell the system that you've consumed the event.

#5

@Adam how can we implement slideNext and slidePrev methods. Please share some code snippet.