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
Posts: 184
Registered: ‎09-03-2012
My Device: Blackberry 10
Accepted Solution

TabbedPane - programatically select a tab?

Hello,

 

Just wondering how do you programmatically select a tab in the example below. E.g. I want to select the kittens tab on startup instead of having the first tab selected.

 

I can use the kittens.triggered() command but the graphic still show the first tab as selected.

 

Thanks!

 

 

// Default empty project template
import bb.cascades 1.0

// creates one page with a label
TabbedPane {
    showTabsOnActionBar: false
    activePane: Page {
        Label {
            id: label
            text: "What do you like more, kittens or puppies?"
        }
    }

    Tab {

        id: puppies
        title: "Puppies"
        onTriggered: label.text = "I love puppies!"
    }

    Tab {

        id: kittens
        title: "Kittens"
        onTriggered: label.text = "I love kittens!"
    }
}

Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: TabbedPane - programatically select a tab?

[ Edited ]

Hi,

 

TabbedPane {
    onCreationCompleted: {
        activeTab = kittens
    }

 upd: fixed. Thanks, Peter. :smileyhappy:

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: TabbedPane - programatically select a tab?

Note, that's onCreationCompleted, with a "d" on the end. (Original post shows just onCreationComplete.)

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!
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook

Re: TabbedPane - programatically select a tab?

Don't forget to name the Tabbed Pane.

 

 

TabbedPane {
    id:mainTabPane
    showTabsOnActionBar: false
    activePane: Page {
        Label {
            id: label
            text: "What do you like more, kittens or puppies?"
        }
    }

    Tab {

        id: puppies
        title: "Puppies"
        onTriggered: label.text = "I love puppies!"
    }

    Tab {

        id: kittens
        title: "Kittens"
        onTriggered: label.text = "I love kittens!"
    }
}

 

ie. mainTabPane

So that you can set the Tab from within another Tab

 

mainTabPan.activeTab = kittens

 I'm doing it from a 2nd tab that contains a NavigationPane.  When the user gets to the final Nav Page and hits save, I pop them back to the TabPane and then send them to the 1st tab.

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 184
Registered: ‎09-03-2012
My Device: Blackberry 10

Re: TabbedPane - programatically select a tab?

It works extremely well. Thanks everyone!

It's a very nice feature... not very well documented though :smileyhappy: