02-25-2013 05:52 AM
Thanks for reading this.
I have an application with three buttons in the menubar (topmenu, swipe down from top bezel), help, info, settings. They can all be opened one after each other. I do not close an open Page, so they are all stacked on top of each other (which can be using using the swipe right.) Now here's the issue, when helpPage is below the settinsPage, I wish that it becomes on top of the settingsPage when I press the button "help" (in the menubar). I couldn't get that to work. But after some searching I found something that works. It may help others too, nevertheless, I also want to if this code is okay. If mean there might be a better way to do this, or worse, this could be a problematic way to do this. Here's the code:
There's a qml file holding the ui elements of the SettingsPage, which also contains code to close the page using the naviationPane.pop() command.
In the main.qml there's some initialization
.
.
NavigationPane {
id: navigationPane
.
.
.
propertyPagesettingsPage
function getSettingsPage() {
if (! settingsPage) {
settingsPage = settingsPageDefinition.createObject();
}
return settingsPage;
}
.
.
attachedObjects: [
ComponentDefinition {
id: settingsPageDefinition
source: "SettingsPage.qml"
},
.
.
Menu.definition: MenuDefinition {
settingsAction: SettingsActionItem {
id: settingsScreen
onTriggered : {
var page = getSettingsPage();
console.debug("pushing settings " + page)
navigationPane.push(page);
navigateTo(settingsPage);
}
}
helpAction: HelpActionItem {
id: helpScreen
onTriggered: {
var page = getHelpPage();
console.debug("pushing help " + page)
navigationPane.push(page);
navigateTo(helpPage);
}
}
.
.
Everything is pretty standard, i.e. what you get iwhen you create an empty project with a navigationpane. The thing I I added to create the functionality that the Page which I ask for by clicking on the button, e.g. "help", appears on top is "navigateTo(helpPage);". Is this a correct use of navigateTo and/or is there a better way.
Thanks a lot for your help!
William
02-25-2013 03:44 PM - edited 02-25-2013 03:44 PM
Normally, you don't have to do this. Because navigationPane.push() will add the screen you give to the top of the stack. Which means that view will be appear on top.
Normally the navigateTo, is more when you want to add more than one view to the stack.
Maybe this site can explain it better than I can :-)
02-25-2013 05:02 PM
Thanx,
I did move the attached object code outside of the actionmenu. Will move it back and watch the change in behavior.