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
ekke
Posts: 1,544
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: OrientationHandler does not support onOrientationAboutToChange signal


smiley wrote:

I have followed the above code and even the sample app and yet my app won't receive the orientation changes.

 

Is there something that I have missed?

 


in the bar-descriptor - application - set orientation to auto-orient

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Developer
smiley
Posts: 1,475
Registered: ‎07-14-2008
My Device: Z10

Re: OrientationHandler does not support onOrientationAboutToChange signal


ekke wrote:

smiley wrote:

I have followed the above code and even the sample app and yet my app won't receive the orientation changes.

 

Is there something that I have missed?

 


in the bar-descriptor - application - set orientation to auto-orient


I have done that.

 

    <initialWindow>
        <autoOrients>true</autoOrients>
        <systemChrome>none</systemChrome>
        <transparent>false</transparent>
    </initialWindow>

The screen does rotate but i'm not receiving the events. Here is the code

 

main cpp

 

    OrientationSupport::instance()->setSupportedDisplayOrientation(SupportedDisplayOrientation::All);

    QObject::connect(
        OrientationSupport::instance(),
        SIGNAL(orientationAboutToChange(bb::cascades::UIOrientation::Type)),
        this,
        SLOT(onOrientationAboutToChange(bb::cascades::UIOrientation::Type)));

    QObject::connect(
        OrientationSupport::instance(),
        SIGNAL(orientationChanged(bb::cascades::UIOrientation::Type)),
        this,
        SLOT(onOrientationChanged(bb::cascades::UIOrientation::Type)));

Slots

 

void testApp::onOrientationAboutToChange(UIOrientation::Type orientation)
{
}

void testApp::onOrientationChanged(UIOrientation::Type orientation)
{
}

 in hpp file

 

public slots:

	void onOrientationAboutToChange(UIOrientation::Type orientation);
	void onOrientationChanged(UIOrientation::Type orientation);

 


thanks

 

 

 

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: OrientationHandler does not support onOrientationAboutToChange signal

is the slot never getting called or you're not getting the proper orientation?

 

There is currently a bug in beta4 where the argument 'orientation' in the orientationChanged signal is never of type Landscape. You have to use OrientationSupport.orientation to detect whether landscape or portrait.

Please use plain text.
Developer
smiley
Posts: 1,475
Registered: ‎07-14-2008
My Device: Z10

Re: OrientationHandler does not support onOrientationAboutToChange signal

the slot is never called.

 

I'm using Beta 3 SDK with the lastest alpha OS.

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: OrientationHandler does not support onOrientationAboutToChange signal

your connect is probably wrong then...

 

where exactly are you calling the connect code ?

 

Please use plain text.
Developer
smiley
Posts: 1,475
Registered: ‎07-14-2008
My Device: Z10

Re: OrientationHandler does not support onOrientationAboutToChange signal


lew wrote:

your connect is probably wrong then...

 

where exactly are you calling the connect code ?

 


TestApp::TestApp(bb::cascades::Application *app)
: QObject(app)
{
    OrientationSupport::instance()->setSupportedDisplayOrientation(SupportedDisplayOrientation::All);

    QObject::connect(
        OrientationSupport::instance(),
        SIGNAL(orientationAboutToChange(bb::cascades::UIOrientation::Type)),
        this,
        SLOT(onOrientationAboutToChange(bb::cascades::UIOrientation::Type)));

    QObject::connect(
        OrientationSupport::instance(),
        SIGNAL(orientationChanged(bb::cascades::UIOrientation::Type)),
        this,
        SLOT(onOrientationChanged(bb::cascades::UIOrientation::Type)));


	// create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

...
}

 

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: OrientationHandler does not support onOrientationAboutToChange signal

that code looks fine to me...maybe there is a bug somewhere with when the signals should be connected?

 

can you try doing it in QML (as i know this one works fine):

onCreationCompleted: {
OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
OrientationSupport.orientationChanged.connect(onOrientationChanged);
}

 

have the slot within the QML for the time being. if it works, you can connect the signal to your c++ slot.

 

let me know if it works!

 

PS: one more thing, putting aside the signal, does your device screen rotate at all?

Please use plain text.
Developer
smiley
Posts: 1,475
Registered: ‎07-14-2008
My Device: Z10

Re: OrientationHandler does not support onOrientationAboutToChange signal


lew wrote:

that code looks fine to me...maybe there is a bug somewhere with when the signals should be connected?

 

can you try doing it in QML (as i know this one works fine):

onCreationCompleted: {
OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
OrientationSupport.orientationChanged.connect(onOrientationChanged);
}

 

have the slot within the QML for the time being. if it works, you can connect the signal to your c++ slot.

 

let me know if it works!

 

PS: one more thing, putting aside the signal, does your device screen rotate at all?


Thanks but i have tried in QML first. 

 

          OrientationHandler {
               id: handler
               onOrientationAboutToChange: {
                   // set some UI to be shown during orientation change
                   if (orientation == UIOrientation.Portrait) {
                       // make some ui changes related to portrait
                   } else if (orientation == UIOrientation.Landscape) {
                       // make some ui changes related to landscape
                   }
                   if (displayDirection == DisplayDirection.North) {
                       // do something specific to this device display direction
                   }
               }
               onOrientationChanged: {
                   // can update the UI after the orientation changed
               }
               onDisplayDirectionChanged: {
                   // can perform actions based on the direction of the display
               }
           },        

 In QML editor it would give error onOrientationAboutToChange.  It has unknown.

 

and yes it does rotate the screen just not getting the signal.

Please use plain text.
Developer
Developer
lew
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha

Re: OrientationHandler does not support onOrientationAboutToChange signal

your QML code is wrong....probably the documentation still hasn't been updated :smileysad:

 

DO NOT use the orientationHandler, it is no longer the way to get the orientation events...use the code i supplied above.

 

onCreationCompleted: {
OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
OrientationSupport.orientationChanged.connect(onOrientationChanged);
}

 

Please use plain text.