BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-15-2007, 08:42 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Nov 2007
Model: 8700c
PIN: N/A
Carrier: AT&T
Posts: 32
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default popupScreen + KeyListener

Please Login to Remove!

I'm trying to code a popupScreen that displays some information and upon a keypress, it disappears. I was trying to do something like this..


Code:
UiApplication.getUiApplication().pushScreen(popupScreen);
That pushes the popupScreen with the label containing the message i want displayed. I added the keylistener to popupScreen.

Code:
popupScreen.addKeyListener(popupScreenKeyListener);
I defined the listener as follows..

Code:
private KeyListener popupScreenKeyListener = new KeyListener()
{
    public boolean keyStatus(int keycode, int time)
    {
        UiApplication.getUiApplication().popScreen(popupScreen);
        return true;
    }
    public boolean keyRepeat(int keycode, int time)
    {
        UiApplication.getUiApplication().popScreen( UiApplication.getUiApplication().getActiveScreen() );
        return true;
    }
    public boolean keyDown(int keycode, int time)
    {
        return true;
    }
    public boolean keyUp(int keycode, int time)
    {
        UiApplication.getUiApplication().popScreen( UiApplication.getUiApplication().getActiveScreen() );
        return true;
    }
    public boolean keyChar(char key, int keycode, int time)
    {
        UiApplication.getUiApplication().popScreen( UiApplication.getUiApplication().getActiveScreen() );
        return true;
    }
};
Neither popScreen(popupScreen) nor the .getActiveScreen() method seem to be popping the popupscreen.

Any ideas as to what i'm doing wrong or missing? Or is there another way of creating a screen with no buttons or images (just text) that goes away when the user presses any key?
Offline  
Old 11-15-2007, 09:55 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

override the keyCar method for popupscreen, you don't need to add a specific key listener:

public boolean keyChar(char key, int status, int time) {
boolean retval = false;
switch (key) {
case Characters.ESCAPE:
UiApplication.getUiApplication.popScreen(UiApplica tion.getUiApplication.getActiveScreen());
return true;
default:
retval = super.keyChar(key, status, time);
}
return retval;
}
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 11-15-2007, 10:14 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Nov 2007
Model: 8700c
PIN: N/A
Carrier: AT&T
Posts: 32
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Got it to work. Also added a trackwheelListener for added functionality. I appreciate the help.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.