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
pyth
Posts: 469
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 :smileysad:. How can I do it?

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Please use plain text.
Developer
simon_hain
Posts: 15,845
Registered: ‎07-29-2008
My Device: Z10 LE
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
Please use plain text.
Developer
pyth
Posts: 469
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
Please use plain text.
Developer
pyth
Posts: 469
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
Please use plain text.