If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
Developer
klz
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook
My Carrier: MTS Ukraine
Accepted Solution

Remove all pages from stack

Hello everyone,

 

I bet that I missed this thing in documentation, but need you help here. So I have a NavigationPane and stack of screens. On screens I have a home button to go back to the "parent" screen. How can I remove all pages from navigation stack exept the first one? I don't really want to push first screen again, because that way I will have to hide back button on bar and i think it is not good for memory.

 

Any suggestions?

 

 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Please use plain text.
Developer
Zmey
Posts: 1,510
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Remove all pages from stack

[ Edited ]

Hi,

 

I think you can use navigateTo method for this (+navigateToTransitionEnded signal to destroy the pages).

Pass the first page to navigateTo. It can be retrieved using navigationPane.at(0)

 

https://developer.blackberry.com/cascades/reference/bb__cascades__navigationpane.html#function-navig...

 

Btw in Cascades if you drag the back button (not the screen itself), it will go straight to the top so separate button may not be neccessary.


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
Developer
klz
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook
My Carrier: MTS Ukraine

Re: Remove all pages from stack

Hello Zmey,

 

Thanks for your suggestions. Will try to do that way. As for back button - I know that, but since I'm developing an app for a client I cannot do everything as I want to. 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Please use plain text.
Trusted Contributor
Brennan12325
Posts: 204
Registered: ‎05-15-2012
My Device: None
My Carrier: Telus

Re: Remove all pages from stack

[ Edited ]

Here's how I've done it, and it should work assuming your root page is the first item pushed onto the stack (which I assume it always will be).

 

while(nav->count() > 1)
    {
        nav->pop();
    }

 Where nav is a pointer to a NavigationPane.

 

edit: So assuming you're willing to do this in C++ just connect the ActionItem triggered() SIGNAL to a SLOT that can access the navigation pane through a class variable.

 

If you're looking for a fully QML solution you could override the back button functionality:

paneProperties: NavigationPaneProperties {
                    backButton: ActionItem {
                        title: "First page"
                        imageSource: "back.png"
                        onTriggered: {
                            navigationPane.pop();
                        }
                    }
                }

 I don't think you can use NavigationPaneProperties in any way to include both a regular back button and a "back to root" button. I'm sure there's a good way to do it in QML but I'm too familiar with QML as I've done this kind of logic mostly in C++.

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!
Please use plain text.
Developer
Developer
klz
Posts: 132
Registered: ‎08-24-2011
My Device: Z10 LE + Playbook
My Carrier: MTS Ukraine

Re: Remove all pages from stack

[ Edited ]

Thanks everyone. Basically it will look like this

 

nav.navigateTo(nav.at(0));

 

Thank you!
----------------------------
My Apps: Alchemy Game | Image Resizer | Jam! | Traffic Signs: USA | Radio Record
My Blog: http://bb10pro.com
Please use plain text.