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
RileyGB
Posts: 284
Registered: ‎08-06-2010
My Device: Z10
Accepted Solution

SettingsActionItem in a TabbedPane

Hey guys,

 

I'm using the standard TabbedPane from the weatherguesser example. I'm trying to get an action item to push a page, but since it's a TabbedPane, pages cannot be pushed. However, I know that this is possible as the Google Talk application does accomplish this somehow. I was wondering if anyone could help point me in the right direction here.

 

Here's a snippet of the relevant code:

 

TabbedPane {
    id: mainTab
    showTabsOnActionBar: true

    // The home weather page that the user can select which city that they want to show
    // here by long pressing a city in the list and setting it as home.
    Tab {
        title: "Home"
        imageSource: "asset:///images/menuicons/icon_home.png"
        HomePage {
            id: homeCityPage

            // The data model and the city property of the home weather is kept in the
            // _homeModel which is created and bound in C++.
            weatherData: _homeModel;
            city: _homeModel.city;
        }
    }

    attachedObjects: [
        ComponentDefinition {
            id: moreInfoPageDefinition
            source: "MoreInfoPage.qml"
        },
    ]


    Menu.definition: MenuDefinition {
        // Add a Help action
        helpAction: HelpActionItem {
        }

        // Add a Settings action
        settingsAction: SettingsActionItem {
            onTriggered: {
                var moreInfoPage = moreInfoPageDefinition.createObject();
                mainTab.push(moreInfoPage);
            }
        }
    }
}// TabbedPane

 



Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: SettingsActionItem in a TabbedPane

You don't actually push the page in the TabbedPane, but rather make the Page that you're displaying in a given tab be a NavigationPane instead of a simple Page, and then you can do the usual push() stuff, at least while on that Tab.

If you have many tabs, and don't like the idea of making each one a NavigationPane, perhaps you need to change the approach so that each Tab references a single NavigationPane, and when you change the active tab you don't actually change the activePane. The way to do this is documented in the TabbedPane docs. It's not very hard, but neither would I call it trivial.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
bcs925
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30
My Carrier: T-Mobile

Re: SettingsActionItem in a TabbedPane

Don't know the specifics of your app but based off the name of the qml file you want "more info page" have you considered using a Sheet{} that contains the information rather than pushing to a new qml file?  Thats typically what I use when using the top menu actions.

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Please use plain text.
Developer
RileyGB
Posts: 284
Registered: ‎08-06-2010
My Device: Z10

Re: SettingsActionItem in a TabbedPane

Thanks for the solutions guys.

 

I made all of my tabs into navigation panes, which they should've been anyways for my purposes. Then I used the following code to ensure proper navigation:

 

        // Add a Settings action
        settingsAction: SettingsActionItem {
            onTriggered: {
                var moreInfoPage = moreInfoDefinition.createObject();
                mainTab.activePane.push(moreInfoPage);
            }
        }

 

Where mainTab is the id of my TabbedPane.



Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
Please use plain text.
Developer
Manuel_Meinen
Posts: 20
Registered: ‎11-28-2013
My Device: BlackBerry Q10
My Carrier: Swisscom

Re: SettingsActionItem in a TabbedPane

I had the same problem but now I did it the way you did it but there is still a bug in my code... like this you can even open up a moreInfoPage while having a moreInfoPage displayed... like this you can open up this page infinitely many times and therefore you have to close it infinitely many times as well. Is there a way to suppress a specific menu item while having displayed a specific page?

Please use plain text.
Developer
RileyGB
Posts: 284
Registered: ‎08-06-2010
My Device: Z10

Re: SettingsActionItem in a TabbedPane

Manuel, simply give your SettingsActionItem an id (such as settingsActionItem), then set settingsActionItem.enabled = false; when the settings page is pushed.



Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
Please use plain text.