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
Highlighted
Developer
Posts: 412
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook
Accepted Solution

SettingsActionItem / NavigationPane in TabbedPane initialization

  I am having a problem getting SettingsActionItem to function properly with dynamic creation of NavigationPanes that are in a TabbedPane.

  The problem is that when I start the app, I create the first tab NavigationPane at the onCreationCompleted signal. If I then try to access the SettingsActionItem, I cannot push anymore pages on the settings page.

  If I select another tab, I can push more pages on the settings page even when I go back to the first tab that wouldn't work the first time. It has to be something with the initialization of the first NavigationPane.

 

import bb.cascades 1.0

// Include asset folders
import "folder1"
import "folder2"
import "folder3"

TabbedPane {
    id: tabbedPane
    showTabsOnActionBar: false

    // Set to first tab id

    property NavigationPane currentNavigationPane: oneNavPaneObject

    property OneNavPane oneNavPaneObject
    property TwoNavPane twoNavPaneObject
    property ThreeNavPane threeNavPaneObject

    // Attached Objects

    attachedObjects: [
        ComponentDefinition {
            id: settingsListPage
            source: "SettingsListPage.qml"
        },
        Sheet{
            id: infoSheet
            InfoPage {
                id: infoPage
                onDone: {
                    infoSheet.close();
                }
            }
        },
        ComponentDefinition {
            id: oneNavPaneDefinition
            OneNavPane { }
        },
        ComponentDefinition {
            id: twoNavPaneDefinition
            TwoNavPane { }
        },
        ComponentDefinition {
            id: threeNavPaneDefinition
            ThreeNavPane { }
        }      
    ]
      
    // Application Menu

    Menu.definition: MenuDefinition {
        id: menu
        actions: [
            ActionItem {
                title: "Info"
                imageSource: "icons/info.png"
                onTriggered: {
                    // For InfoPage, we will use Sheet
                    infoSheet.open();
                }
            }
        ]
        settingsAction: SettingsActionItem {
            imageSource: "icons/settings.png"
            onTriggered: {
                // For Settings, we will use NavigationPane
                var settingsListPageObj = settingsListPage.createObject();
                Application.menuEnabled = false;
                currentNavigationPane.push(settingsListPageObj);
            }
        }
    } 
    
    // Tabs

    Tab {
        id: oneTab
        title: qsTr("One")
        imageSource: "icons/one.png"
        onTriggered: {
            oneNavPaneObject = oneNavPaneDefinition.createObject()
            currentNavigationPane = oneNavPaneObject
            oneTab.content = oneNavPaneObject
        }
    }
    Tab {
        id: twoTab
        title: qsTr("Two")
        imageSource: "icons/two.png"
        onTriggered: {
            twoNavPaneObject = twoNavPaneDefinition.createObject()
            currentNavigationPane = twoNavPaneObject
            twoTab.content = twoNavPaneObject
        }
    }
    Tab {
        id: threeTab
        title: qsTr("Three")
        imageSource: "icons/three.png"
        onTriggered: {
            threeNavPaneObject = threeNavPaneDefinition.createObject()
            currentNavigationPane = threeNavPaneObject
            threeTab.content = threeNavPaneObject
        }
    }
    onCreationCompleted: {
        oneNavPaneObject = oneNavPaneDefinition.createObject()
        currentNavigationPane = oneNavPaneObject
        oneTab.content = oneNavPaneObject
    }
}

 

Developer
Posts: 412
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: SettingsActionItem / NavigationPane in TabbedPane initialization

Solved: Solution was to set the active tab.

 

    onCreationCompleted: {
        oneNavPaneObject = oneNavPaneDefinition.createObject()
        currentNavigationPane = oneNavPaneObject
        oneTab.content = oneNavPaneObject
        tabbedPane.activeTab = oneTab
    }