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

Native Development

Reply
Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Custom Back Behaviour

I have a NavigationPane and in the second page, I have a ListView where I navigate inside a hierchical structure using the same LisTview and page (I refresh the screen to let the user know where he/she is now).
I use a custom management for the back button so i come back to first page if the hierarchy is on "root". Everything works fine but i would like to capture the swipe to right gesture to going back in the hierarchy because now it shows me the first page...

 

Any hint...

 

 

Developer
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10
My Carrier: -

Re: Custom Back Behaviour

Add peekEnabled: false to your QML code:

 

NavigationPane{
    peekEnabled: false
    // your code here
}
----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!
Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Custom Back Behaviour

Thanks

For this disableswipe to go back.. What I like is swipe to my previous item in the hierarchy .

I guess it is not possible because I did not put the new information in a page and "pushed" into the NavigationPane..

 

Another suggestion or am I right about this ?

 

 

Developer
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10
My Carrier: -

Re: Custom Back Behaviour

[ Edited ]

There is a way! You could make certain elements visible and invisible depending on which ones you want to show. Have a touch event sense where your press down and where you lift it up. The code whould resemble something like this:

 

property int xloc;
property int yloc;

.
.
.

onTouch:{
  if (event.touchType == TouchType.Down){
    xloc = event.screenX
    yloc = event.screenY
  }
  else if(event.touchType == TouchType.Up){
  \\ you can check here if it's not an up swipe with event.screenY
    if(xloc - event.screenX > 300){
      \\ swipe to the left
    }
    else if(xloc - event.screenX < -300){
      \\ swipe to the right
    }
  }
}

 Edit: I can get you the exact code tomorrow morning. For now you can refer to the TouchEvent page.

----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!
Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Custom Back Behaviour

Thanks

I need to change event.screenX and event.screenY for event.windowX and event.windowY.

But it did not work as desired...

Also I add the code the the main container on that page because Page does not have the onTouch event...

Developer
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10
My Carrier: -

Re: Custom Back Behaviour

Placing it in the main container is perfectly fine. As promissed, I've found the actual code (I think there were errors in the previous one I posted). Give it another try:

 

 onTouch: {
                    if (event.isDown()) {
                        downX = event.windowX;
                        downY = event.windowY;
                    } else if (event.isUp()) {
                        var yDiff = downY - event.windowY;
                        // take absolute value of yDiff
                        if (yDiff < 0) yDiff = -1 * yDiff;
                        // I check if the minimum y movement is less than 200.  Don't want to move left or right if 
                        // the user is actually want to move up or down.
                        if ((yDiff) < 200) {
                            if ((downX - event.windowX) > 320) {
                                // move right
                            } else if ((event.windowX - downX) > 320) {
                                // move left
                           }
                        }
                    }
                }

 Again, at the "move left" or "move right", you could make the items visible:false, which is what i usually do, or anything else really. Don't forget to #include <bb/cascades/TouchEvent>.

----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!
Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Custom Back Behaviour

Thanks