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: 100
Registered: ‎04-01-2014
My Device: BlackBerry10 Simulator
My Carrier: none

button to main page

Hi there,

 

I'm developing an app that opens a list view of files. When you click on one of then a new Page is opened displaying the content of the file.

 

The other way I implemented is by clicking on a file and opening it directly in the app (means without passing the mainpage).

 

Logically there is now no "Back-Button" to go to the main page. Can anybody tell me how I can add a button, like the usual back button in the left lower corner to go to the main page.


I found several solutions (http://developer.blackberry.com/native/reference/cascades/bb__cascades__navigationpaneproperties.htm... but they didn't work so far.

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: button to main page

[ Edited ]

If you have a NavigationPane and you have pushed a page then the back button should be there, can you post your code?


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 100
Registered: ‎04-01-2014
My Device: BlackBerry10 Simulator
My Carrier: none

Re: button to main page

[ Edited ]

Yes that's true. When I do the thing you say the back button is there.

 

But now I have a different approach. Instead of opening the app by touching the app button on the Blackberry Screen and then open a file from a listView on my main page I look into the folder of my Blackberry (without opening the app). When I then click on the file it is opened via an Invocation.

 

void ApplicationUI::handleInvoke(const bb::system::InvokeRequest& request) {

	// Initiate the appropriate target based on the invoke.target-key
	if (request.target() == "com.application.reader.card.previewer") {

		initPreviewerUI();

		ApplicationUI::fillPageWithDetails(File_With_Content_To_Fill_Page);
}

 The initPreviewerUI()-function leads directly to my PageDetails-Page without coming from the MainPage. So there logically is no back button.

 

But I want to also from that page go back to the main page. How can I do that?

EDIT:

 

Okay, also the former approach with push(page) doesn't work.

Here is what I do differently:

The version that works perfecty and shows me a back button:

onTriggered: {
    var selectedItem = dataModel.data(indexPath);
    var contentpage = secondPageDefinition.createObject();
             
    navigationPane.push(page);           
}

attachedObjects: [
    ComponentDefinition {
        id: secondPageDefinition
        source: "asset:///PageDetails/PageDetails.qml"
    }
]

 This version doesn't show me a back button:

onTriggered: {
    var selectedItem = dataModel.data(indexPath);
    var page = Qt.app.fillPageWithDetails(selectedItem.toString());
                    
    navigationPane.push(page);
}

 The fillPageWithDetails()-function does basically the following:

Page* ApplicationUI::fillPageWithDetails(QString fn) {
  QmlDocument *qml = QmlDocument::create("asset:///PageDetails/PageDetails.qml").parent(this);
  qml->setContextProperty("app", this);

  Page* newPage = qml->createRootObject<Page>();

  AbstractPane *root = qml->createRootObject<AbstractPane>();

/*
* fill Page with content
*/ return newPage; }

 Can you tell me where the back button gets lost? Or maybe isn't created because of something.

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: button to main page

There's not really enough detail there for me to say why you are not getting the button.

If you are pushing the same page and going through the same logic whether you invoke or start the app normally then the button should be there.

My best guess at this point is that you are not going through the same process for each and possibly not allowing time for something to initialise.

If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 100
Registered: ‎04-01-2014
My Device: BlackBerry10 Simulator
My Carrier: none

Re: button to main page

The missing back button is definetely caused because I create the page in C++  instead of QML. I will check what I the exact difference is and post it, when I found it.

Developer
Posts: 16,676
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: button to main page

instead of creating and pushing the detail page only i would suggest that you create the start page, push it and then push the detail page on top.
you will have the back button on the detail page and the user can return to the start page with it.
----------------------------------------------------------
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