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
Highlighted
New Contributor
Posts: 6
Registered: ‎04-10-2014
My Device: BlackBerry OS 7.0 , model 9900
My Carrier: mobile
Accepted Solution

Where is the control events of the track pad for blackberry.

There is  an application for blackberry. It need move the PAGE at the between of the screen right or left by touch the track pad.

Now, it  moves to right and left . BUT some times two PAGEs (half and half) will remain one screen.

How can I control one Page to one screen by track pad. Or how can I restrict moving for this page by track pad.

 

Could you provide the control events for track pad?

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

Re: Where is the control events of the track pad for blackberry.

You haven't given us much toi go on here, there are lots of different ways of doing what you are describing and the solution will be dependent on which way you have sone it.

 

So if the following doesn't help, please create a small test that we can run, that demonstrates the problem, and paste it in here.  Then we can try to run your code and see the problem and test the solutions.  So we need to be able to run your test code without any of your other classes. 

 

But can you tell us what are you using currently to detect the trackpad swipes?

 

I presume you have some sort of HorizontalFieldManager and the scroll is only going 1/2 way which is why you are seeing two pages at the same time.  You can detect scroll movement and try to make sure it does not stop 1/2 way yourself using a scoll listener.  Alternatively, if you set focus on some Field, Managers will tyupically scroll to make sure that the entire Feild is displayed, so you can get the Manager to do the scrolling.

New Contributor
Posts: 6
Registered: ‎04-10-2014
My Device: BlackBerry OS 7.0 , model 9900
My Carrier: mobile

Re: Where is the control events of the track pad for blackberry.

I paste the  relevant code for touchevent. Please check it.

1. I used the TouchEvent, it can scrolling by touchscreen, but the trackpad can`t get the event.

2.Is this code wrong (Highlight red)? if yes,then what ways can we control the trackpad?

 

//#ifndef VER_4.6.1 | VER_4.6.0 | VER_4.5.0 | VER_4.2.1 | VER_4.2.0

    protected boolean touchEvent(TouchEvent message) {

        

     

     

        int eventCode = message.getEvent();                 

        int touchX =  message.getX(1);

        int touchY =  message.getY(1);

       

     if (touchX < 0 || touchY  < 0 || touchX > getExtent().width || touchY  > getExtent().height) {

           // Outside the field

        return false;

    }

        

     

     if (eventCode == TouchEvent.GESTURE) {

            TouchGesture gesture = message.getGesture();

               switch(gesture.getEvent()) 

               {

                 case TouchGesture.NAVIGATION_SWIPE:

                  Dialog.alert("Swipe direction: " + gesture.getSwipeDirection()  

                          +            ", "

                          +            "\nMagnitude: " + gesture.getSwipeMagnitude());

                   return false;

               }

     

     }

     

      

    if (eventCode == TouchEvent.GESTURE) {

           int direction = message.getGesture().getSwipeDirection();

               

           if (direction == TouchGesture.SWIPE_WEST)

           {

              System.out.println("TouchGesture.SWIPE_WEST............");

           }

           else if (direction == TouchGesture.SWIPE_EAST)

           {

              System.out.println("TouchGesture.SWIPE_EAST............");

           }

          

             

           return true;

       }

      

        

       if(eventCode == TouchEvent.DOWN) {    

         System.out.println("TouchGesture.DOWN............");

        }

       

            

        if(eventCode == TouchEvent.MOVE) {

          

           System.out.println("TouchGesture.MOVE............");

            

        } 

        

        if (eventCode == TouchEvent.CANCEL)

        {

           System.out.println("TouchGesture.CANCEL............");

        }

        

        if (eventCode == TouchEvent.UP)

        {

           System.out.println("TouchGesture.UP............");

        }

        return false;

    }

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

Re: Where is the control events of the track pad for blackberry.

I usually detect movement on the trackpad by overriding navigationMovement(...).  Have a look at that.

New Contributor
Posts: 6
Registered: ‎04-10-2014
My Device: BlackBerry OS 7.0 , model 9900
My Carrier: mobile

Re: Where is the control events of the track pad for blackberry.

Haaaaa,it resovled ,thank you very much.