11-14-2012 10:25 AM
I've checked out the docs, and it appears that there is only one reference to displayLandcape and no mention of which way the phone is round.
How can I get it so that my app supports both right-landscape and left-landscape, so when you turn the phone upside down (but still landscape) the app screen rotates.
Thanks
11-14-2012 10:36 AM
You can use OrientationHandler for that, like this:
OrientationHandler {
onOrientationAboutToChange: {
if (orientation == UIOrientation.Landscape) {
//do stuff
} else {
//do other stuff
}
}
}
(you can check this out in Ekkes open source app, see https://ekkescorner.wordpress.com/ )
11-14-2012 10:39 AM
It's handled automatically with absolute postioning. He is what I used for testing. Just add a 300 x 300 png and try it out.
// Default empty project template
import bb.cascades 1.0
// creates one page with a label
Page {
Container {
id: rootContainer
background: background.imagePaint
attachedObjects: [
ImagePaintDefinition {
id: background
repeatPattern: RepeatPattern.XY
imageSource: "asset:///pattern/grasstile.png"
},
OrientationHandler {
id: handler
onOrientationAboutToChange: {
if (orientation == UIOrientation.Portrait) {
logo.preferredWidth = 150.0
logo.preferredHeight = 150.0
} else if (orientation == UIOrientation.Landscape) {
logo.preferredWidth = 300.0
logo.preferredHeight = 300.0
}
}
onOrientationChanged: {
}
onDisplayDirectionChanged: {
}
}
]
layout: AbsoluteLayout {
}
ImageView {
id: logo
imageSource: "asset:///images/logo300.png"
scalingMethod: ScalingMethod.None
layoutProperties: AbsoluteLayoutProperties {
positionX: 50.0
positionY: 50.0
}
preferredWidth: 150.0
preferredHeight: 150.0
}
onCreationCompleted: {
OrientationSupport.supportedDisplayOrientation =
SupportedDisplayOrientation.All;
}
}
}
11-14-2012 10:46 AM
11-14-2012 10:49 AM
If you try out the code, you will see that you get the same look whether left or right landscape mode. At least it works that way on my Alpha Dev device.
11-14-2012 10:59 AM
it's entirely valid to want to know whether you are in a clockwise rotated landscape orientation or a counter-clockwise rotated landscape orientation.
for example, you may care about which way the accelerometers on the physical device are now oriented, or which way the camera is now positioned so that you can take pictures correctly.
in any event, search the Cascades docs for DisplayDirection. You will see that this property is exposed in various orientation-related objects and handlers, etc.
Cheers,
Sean
11-14-2012 11:07 AM - edited 11-14-2012 11:57 AM
11-14-2012 11:56 AM - edited 11-14-2012 11:57 AM
I have orientation working. I can do one rotation and the display changes etc. Any subsequent orientation changes have no effect with the error:
Warning: bb::cascades:
rientationSupport(0x172668) onOrientationCheck: Wrong state when receiving orientation check: 1
Any ideas?
11-14-2012 12:19 PM
There is some sample code in the docs you might want to look at.
https://developer.blackberry.com/cascades/referenc
11-14-2012 12:25 PM - edited 11-14-2012 12:44 PM
But that's for QML, not C++.
I converted it to C++ and I still get the same error:
Warning: bb::cascades:
rientationSupport(0x190668) onOrientationCompleted: Wrong state when receiving orientation completed: 1