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

Web and WebWorks Development

Reply
Highlighted
Developer
Posts: 135
Registered: ‎09-25-2012
My Device: Dev Alpha
My Carrier: Rogers
Accepted Solution

Application.Orientation (Can't unlock...)

Basically, my app allows the user to switch orientation and basically the UI will change based on it. However, there are few screens which I want to lock the orientation (settings & help for example).

 

I am using bbui.js (0.9.6) and use the ondomready: function to check the page (id) to lock and unlock orientation.

 

[...]
ondomready: function(element, id, params) {
if (id == 'menu') {
blackberry.app.unlockOrientation();
} 
if (id == 'settings') {
blackberry.app.lockOrientation ('portrait-primary');
} 
if (id == 'help') {
blackberry.app.lockOrientation ('portrait-primary');
}
[...]

 

I am able to get it to lock to portrait, but I can't seem to unlock it. I even tried to putting an "onclick" event on the actionbar (back) button to see if it will work. It doesn't. Any clue on what I am doing wrong here?

 

Thanks.

Developer
Posts: 135
Registered: ‎09-25-2012
My Device: Dev Alpha
My Carrier: Rogers

Re: Application.Orientation (Can't unlock...)

OK... I solved my own problem. It works when I call a new function instead of having it within the ondomready function.

 

So, I made these functions.

function lockDisplay()
{
	blackberry.app.lockOrientation('portrait-primary');
}

function unlockDisplay()
{
	blackberry.app.unlockOrientation();
}

 

Call them from within the ondomready... and it works.