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
Trusted Contributor
Posts: 117
Registered: ‎09-06-2011
My Device: 9900
Accepted Solution

Native screen over QT - listen for orientation

I am struggling to listen for playbook orientation change when a native screen is being shown over the top of a QMainWindow, resize() gets called only when the native screen isnt shown.

 

I have tried to add case NAVIGATOR_ORIENTATION to handle_navigator_event but it never gets called.

 

Anyone have experience of this?

 

Thanks

Developer
Posts: 90
Registered: ‎10-30-2011
My Device: Blackberry Playbook

Re: Native screen over QT - listen for orientation

[ Edited ]

This isn't really how you should be doing it. Qt sets up all of this stuff already. If you try to do it the 'native' way, you will be duplicating this functionality.

 

You will need to grab a handle to the native screen from Qt itself if you want to use the native API on top of Qt. Then you can run a thread that checks BPS events and they shouldn't interfere.

 

I would suggest using Qt to notify you of orientation changes though.

Trusted Contributor
Posts: 117
Registered: ‎09-06-2011
My Device: 9900

Re: Native screen over QT - listen for orientation

Thanks for your reply xsacha,

 

I think I am already doing what you suggest - the following is a function which gets called by starting a pthread.

 

void* MyWindow::keyboard_thread(void* args)
{
	
	MyWindow* mw = (MyWindow*)args;

	bps_initialize();
	dialog_request_events(0);
	screen_request_events(screencontext);
	navigator_request_events(0);

	virtualkeyboard_request_events(0);
	if (BPS_SUCCESS != navigator_rotation_lock(false)) {
	    fprintf(stderr, "navigator_rotation_lock failed\n");
	   
	}
	
	while(!exit_application)
	{
		while (mw->connected) {
			
			/* Handle user input */
			handle_events(mw);
			
		}
	}
	keyboardthread = NULL;

	gestures_cleanup();
}

 

handle_events checks for screen or navigator domain and handles appropriotly,  I just never get NAVIGATOR_ORIENTATION event in handle_navigator_event - is there anything I could be missing?

Developer
Posts: 90
Registered: ‎10-30-2011
My Device: Blackberry Playbook

Re: Native screen over QT - listen for orientation

Oh ok, where's your code for handling navigator events?

 

Is it like this?

switch (bps_event_get_code(event)) {

case NAVIGATOR_ORIENTATION: ....

...

}

Trusted Contributor
Posts: 117
Registered: ‎09-06-2011
My Device: 9900

Re: Native screen over QT - listen for orientation

Hi xsacha,

 

here's my code..

 

 

void
handle_navigator_event(bps_event_t *event) {
switch (bps_event_get_code(event)) {
case NAVIGATOR_EXIT:
exit_application = 1;
break;

case NAVIGATOR_ORIENTATION:
cout << "orienation";
cout.flush();
break;
}
}

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: Native screen over QT - listen for orientation

out of curiousity - why did you go with separate thread for 'keyboard'?

Qt let's you 'intercept' and react to any bps (Native) events...

Trusted Contributor
Posts: 117
Registered: ‎09-06-2011
My Device: 9900

Re: Native screen over QT - listen for orientation

Hey BGmot,

 

I went with a separte pthread when everything was still very new to me in c/c++ & qt. 

 

How do you intercept these events exactly - do you have a link to get me on the right path?

 

Thanks

 

 

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: Native screen over QT - listen for orientation

Trusted Contributor
Posts: 117
Registered: ‎09-06-2011
My Device: 9900

Re: Native screen over QT - listen for orientation

Thank you.

 

so thats how it's done - properly!

 

Thank you both to BGmot and xsacha for your help.

 

Regards.

Trusted Contributor
Posts: 117
Registered: ‎09-06-2011
My Device: 9900

Re: Native screen over QT - listen for orientation

Sorry about this guys, 

 

I have implemented what's suggested in the link provided for eventFilter and eventFilter function is called but I am never getting the event == to screen or navigator domain although the eventfilter function is called when the rotation of device takes place..

 

 

if (domain == navigator_get_domain()) {
handle_navigator_event(event);
} else if (domain == screen_get_domain()) {

handle_screen_event();

}

else

{

//eventfilter justs fall through to here

}

 

anyone any ideas why I cant get the event == to screen or navigator domain?