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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space
Accepted Solution

Get property of top page on navigation stack

[ Edited ]

Hi everyone

 

I have a navigation stack, and I'm pushing pages onto it (sometimes even several times the same page, just with different content)

 

The pages are custom pages

 


Now I have the problem that I need to get a specific property of the topmost page, and that property needs to be referenced from the navigation pane

 


so my code for that looks like this:

 

//****************
//***CustomPage.qml
//********
import bb.cascades 1.2
Page {
    property variant titleLabel
   
    Container {} 
}





///This code is in my navigation pane, in a function

var top = navigationPane.top; //top is a custom page, CustomPage

//how to reference top.titleLabel ?

 

 

I can't set it, I can't get it. I guess it is because top is an unknown class Smiley Sad. How can I do it?

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Get property of top page on navigation stack

did you add some console output?
you could check the objectName of top to see if it is the correct page before you try to access the property, or just use a try/catch (dirty, but it works...)
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: Get property of top page on navigation stack

yes I did. It is the correct page, and currently I'm using the objectname to pass the property additionally, like

 


//page is created

var page = customPageDefinition.createObject();
            page.titleLabel =
            page.objectName = "Banana";
            navigationPane.push(page);

 

 

 

and as soon as I'm trying to read, it gives me the correct objectname. But calling top.titleLabel says [undefined] and the function ends

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Highlighted
Developer
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: Get property of top page on navigation stack

oh, the joys of debugging :/

 

Found the solution for my problem: restarted Momentics, restarted my debugging device, now it works as expected (and it only cost my 3 hours of my life)

 

Sorry for the trouble

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o