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

Java Development

Reply
Highlighted
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Inter screen communication

Hi all.

 

Is there any way to make one screen communicate to the other one (i.e., send/let through keycodes)? 

 

This is what I need:

 

My app has main screen. 

On top of that (on occasion) I push a popup. 

 

Now, I have full control over the popup that is on top. But I need certain keys to be tranparent to the popup. 

For instance, if the User presses the END key, I don't want the popup to consume it, but to let it through to the main screen which is in backround it can then, update its fields accordingly).

 

In other words, main screen must be blind to the fact that there is a popup on top of it. If User sends some 'special' key (known by the popup, of course)  the popup will simply ignore it and pass it through to the next app (in this case the main screen) and the main screen will think it got the input from the User directly.

 

I already tried not consuming the keycode but the main screen doesn't react to it.

 

Any suggestions ?



"Listen carefully, I shall say this only once"
Developer
Posts: 342
Registered: ‎02-04-2009
My Device: BB 8320

Re: Inter screen communication

Key events are consumed by the screen which presently has focus (top of the stack). 


Use Search. "Accept Solution" if the problem gets resolved.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Inter screen communication

@baskaraninfo is absolutely correct, so this means you have to catch the events and throw the ones you want to pass on to the listening screen.

 

As an example assume you want to send the character A to the lower level screen.

 

In your popUpScreen, you know the lower screen as _lowerScreen.  In the popup you override keyChar, and when you detect A, you invoke

lowerScreen.keyChar(.....);

 

Does this do it for you?

Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Inter screen communication

@peter_strange

Unfortunately no.

Because the popup (I forgot to say, sorry) does not know what screen is in the background. 

(If there is none, it could let through the key even to the home screen).

 

@baskaraninfo

 

I was confused with the signature:

protected boolean keyControl(char c, int status, int time)

 

 and the explanation of the return value: 

   "True if event was consumed; otherwise, false. "

 

Now I realize that the screen did receive the event, but did not consume it. I hoped that the event will then be forwarded on to the next screen Smiley Sad  (where does it go, indeed?)

 

 So there is no way to do this (other than removing the popup, injecting the key, pushing the popup back on top) ?



"Listen carefully, I shall say this only once"
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Inter screen communication

You can use getScreenAbove() and getScreenBelow() methods.

Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Inter screen communication

[ Edited ]

That's exactly what I was trying next.

 

Thank you all.

 

Message Edited by myraddin on 04-29-2009 02:44 PM


"Listen carefully, I shall say this only once"
Developer
Posts: 342
Registered: ‎02-04-2009
My Device: BB 8320

Re: Inter screen communication

[ Edited ]

@ myraddin says:

"For instance, if the User presses the END key, I don't want the popup to consume it, but to let it through to the main screen which is in backround it can then, update its fields accordingly"

 

If popup is on top, what is the need of updating the screen on bottom of the popup. Is there any specific need for that? 

 

Edit: Sorry, I am in editing

Message Edited by baskaraninfo on 04-29-2009 08:48 AM

Use Search. "Accept Solution" if the problem gets resolved.
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Inter screen communication

Currently I am prototyping, so I only want to see if I can have this option ...



"Listen carefully, I shall say this only once"
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Inter screen communication

[ Edited ]

Your solution (pop, inject, push) may work, never tried anything like that. 

 

However perhaps there is an alternative.

 

You will note that there is a <Screen>.getScreenBelow().  So the PopupScreen can get a reference to the invoking Screen indirectly.  Then it can invoke an Screen related methods.

 

However if you are pushing a Global Screen (which seems likely) then that won't work.

 

But just to confirm the original response, As far as I know, events are not automatically forwarded to the next screen.

 

Edit: oppsss didn't notice all the activity while I was in Edit.

Message Edited by peter_strange on 04-29-2009 02:32 PM
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Inter screen communication

[ Edited ]

 

Well I am trying to use getScreenBelow() approach, but unfortunately all key* methods are unavailable (protected).

 

So I am  forced to use dispatchKeyEvent().

 

Edit: still no luck, the event doesn't get dispatched, or the lower screen doesn't accept it Smiley Sad

 

Message Edited by myraddin on 04-30-2009 08:59 AM


"Listen carefully, I shall say this only once"