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
gpatton
Posts: 193
Registered: ‎12-29-2010
My Carrier: Rogers
Accepted Solution

Sheet as a Component Defintion

Hi,

I was creating application menus in my application, below the root TabbedPane. Followed the docs online.

I realized that I have to create a Sheet, and can't create a Page. Which is fine. I was hoping for a back-button-esque page.

 

For NavPanes, I know we can create Pages as a Component Definition, so they can be loaded only when needed. I can't do the same for Sheets. Is this is a known limitation?

 

I've done the following, but it doesn't work:

mainTabPane.qml



TabbedPane {
    id: mainTabPage

    Menu.definition: MenuDefinition {
        actions: [
            ActionItem {
                title: "About"
                onTriggered: {
                    aboutSheetDefinition.open();
                }
            }
        ]
    } // end of Menu defintion

    attachedObjects: [
        ComponentDefinition {
            id: aboutSheetDefinition
            source: "about.qml"
        }
    ]
    Tab {
        ...
    }
}

 And then in the about.qml

import bb.cascades 1.0

Sheet {
    id: aboutSheet
    content: Page {
        id: aboutPage
        Container {
            Label {
                text: "This is the ABOUT page"
            }
        }
    }
}

 

 

However, if I do the following, it works. But I want it to work the way I've shown above----^^^ (mainTabPane.qml)

 

TabbedPane {
    id: mainTabPage

    // Application Menu
    Menu.definition: MenuDefinition {
        actions: [
            ActionItem {
                title: "About"
                onTriggered: {
                    aboutSheet.open();
                }
            }
        ]
    } // end of Menu defintion
    
    attachedObjects: [        
        Sheet {
            id: aboutSheet
            content: Page {
                id: aboutPage
                Container {
                    Label {
                        text: "This is the ABOUT page"
                    }
                }
            }
        }
    ]
    Tab {
        ...
    }
}

 

Please use plain text.
Developer
gpatton
Posts: 193
Registered: ‎12-29-2010
My Carrier: Rogers

Re: Sheet as a Component Defintion

[ Edited ]

Never mind. Found my solution.

 

In the ActionItem's onTriggered, have to do the following, i.e. create the aboutSheet variable object, and THEN open it.

 

onTriggered: {
                    var aboutSheet = aboutSheetDefinition.createObject();
                    aboutSheet.open();
                }

 

The attached object, stays the same.

 

attachedObjects: [
        ComponentDefinition {
            id: aboutSheetDefinition
            source: "about.qml"
        }
    ]

 

Please use plain text.
Visitor
zeroseven02
Posts: 1
Registered: ‎05-03-2013
My Carrier: AT&T

Re: Sheet as a Component Defintion

I'm actually having this same problem. Only, with the same setup, it is not working for me.

 

Do you have any extra includes for ComponentDefinition use or the createObject() member?

Please use plain text.