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
Contributor
Posts: 22
Registered: ‎04-12-2010
My Device: z10
My Carrier: AT&T
Accepted Solution

Hide Actionbar

I'm trying to hide the actionbar inside of an actionitem ontriggered event and it is not working.  This is the code I'm trying to use. 

 

            ActionItem {
                id: hsActionBar
                title: "Hide Bar"
                imageSource: "asset:///images/ic_settings.png"       
                onTriggered: {    
                    if(hsActionBar.title == "Hide Bar") {
                        hsActionBar.title = "Show Bar"
                        actionBarVisibility: ChromeVisibility.Hidden
                    }
                    else {
                        hsActionBar.title = "Hide Bar"
                        actionBarVisibility: ChromeVisibility.Visible
                    }
                }
            }

 

This other forum has close to what I'm looking for except it changes the visibility in a new page.  If I place the actionbarvisibility outside of the actionitem in the page outside of any containers it works fine.  However it won't allow me to use an If Then statement outside of a container.

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Hide Actionbar

That's not syntactically correct anyway. You're putting what look like property bindings inside JavaScript code, so it's definitely not going to work.

Closer to what you want would be just to assign, as in actionBarVisibility = ChromeVisibility.Visible.

Depending on where this ActionItem is (i.e. what it's defined inside) this may be sufficient. The ActionItem itself doesn't have a property called actionBarVisibility, so presumably you plan to adjust this property on a containing Page.

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!
Contributor
Posts: 22
Registered: ‎04-12-2010
My Device: z10
My Carrier: AT&T

Re: Hide Actionbar

Thanks, can't believe I messed up the syntax. Works great now.

onTriggered: {
if(hsActionBar.title == "Hide Bar") {
hsActionBar.title = "Show Bar"
actionBarVisibility = ChromeVisibility.Hidden
}
else {
hsActionBar.title = "Hide Bar"
actionBarVisibility = ChromeVisibility.Visible
}
}