1

How to call a screen while clicking a button in Blackberry 10 cascades? I have tried this code but it's not working,

Button {
  text: "Sign-in"
  onClicked: main.qml
}

Can any one send me some sample codes, for on-click function?

Thanks

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
Vendetta
  • 513
  • 2
  • 16
  • This is not exactly an "onClick" function, but I suppose you're trying to do [this](https://developer.blackberry.com/cascades/reference/bb__cascades__navigationpane.html)? – Dielson Sales Nov 29 '12 at 03:34

1 Answers1

1

To show a new Page you'll need to define a NavigationPane and push the Page onto that. Example:

import bb.cascades 1.0

NavigationPane {
    id: navigationPane
    Page {
        Button {
            text: "Sign-in"
            onClicked: {
                var page = secondPageDefinition.createObject();
                navigationPane.push(page);
            }
            attachedObjects: [
                ComponentDefinition {
                    id: secondPageDefinition
                    source: "DetailsPage.qml"
                }
            ]
        }
    }
}

The nice thing about this is that NavigationPane takes care of the back button automatically for you.

When you create a new BlackBerry Cascades project in Momentics choose the NavigationPane template for something very similar to this.

donturner
  • 17,867
  • 8
  • 59
  • 81