04-29-2009 08:04 AM
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 ?
04-29-2009 08:26 AM
@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
Does this do it for you?
04-29-2009 08:39 AM
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).
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 (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) ?
04-29-2009 08:43 AM - edited 04-29-2009 08:44 AM
That's exactly what I was trying next.
Thank you all.
04-29-2009 08:46 AM - edited 04-29-2009 08:48 AM
@ 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
04-29-2009 08:49 AM - edited 04-29-2009 09:32 AM
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.
04-30-2009 01:51 AM - edited 04-30-2009 02:59 AM
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