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
shreyansjain
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360
Accepted Solution

Destroy Page in NavigationPane when Peek used

Hi,
Is it possible to destroy a page when swipe back (peek) gesture is used to pop the page from the NavigationPane? I dont want to use the property 'peekEnabled: false' as I like the peek gesture. I can't use the onPopTransitionEnded signal as I dont know the id of the page which will be popped (using ComponentDefinition).
The following is a snippet of the code:

QML File 1:
NavigationPane {
        id: navPane
	CustomControlPage{

        }
}

CustomControlPage.qml
Page{
...

  onTriggered:{
// I need to create a new Object everytime and that is causing the  problem when peek gesture is used rather than back button as with backButton, I can just use paneProperties and then do pageID.destroy();

    var newPage = newCustomPage.createObject();
    newPage.variant1 = "hello,";
    newPage.variant2 = "world!"
    navPane.push(newPage);
  }
  attachedObjects:[
   ComponentDefinition{
    id: newCustomPage
    source: "newCustomPage.qml"
   }
  ]
}

newCustomPage.qml
Page {
 id: newPage
 property variant variant1
 property variant variant2
...

paneProperties: NavigationPaneProperties{
  ActionItem{
   title: "Back"
   onTriggered {
      newePage.destroy();
   }
 }
}
}

 Thanks!

Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Destroy Page in NavigationPane when Peek used

Hi,
The page which is being popped is passed as 'page' parameter to onPopTransitionEnded, simply delete the page in it:

onPopTransitionEnded: { page.destroy(); }

Andrey Fidrya, @zmeyc on twitter
Developer
shreyansjain
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360

Re: Destroy Page in NavigationPane when Peek used

Ok, So, I dont need the pageID in order to destroy it in the onPopTranisitionEnded signal?

 

just checking, is onPopTransitionEnded same as peek/back button for pop'ing a page?

 

Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Destroy Page in NavigationPane when Peek used

[ Edited ]

Yes, this is correct. 'page' is a parameter, it points to the page you need to destroy.

popTransitionEnded is called when the page is closed using a back button or closed using the peek gesture.

 

It might not be called if you remove the page programmatically, I'm not sure about this.


Andrey Fidrya, @zmeyc on twitter
Developer
shreyansjain
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360

Re: Destroy Page in NavigationPane when Peek used

Thank you, I will try this and will update the page subsequently.

 

Developer
shreyansjain
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360

Re: Destroy Page in NavigationPane when Peek used

Thanks, that worked!
Btw, i used the QML for push'ng and pop'ng the pages!

 

S.