BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-15-2007, 09: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, 10: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, 11: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

HP 1GB 44pin IDE Flash Memory Module 659064-001 8C.4ED16.7256B
$9.99
HP 1GB 44pin IDE Flash Memory Module 659064-001 8C.4ED16.7256B pictureOkuma OPus 5000 Bubble Memory Card EO227-702-004 E4809-045-011-E 077-A 038-C
$375.0
Okuma OPus 5000 Bubble Memory Card EO227-702-004 E4809-045-011-E 077-A 038-C pictureALLEN BRADLEY 634486 MEMORY MODULE 7300UPG5
$49.99
ALLEN BRADLEY 634486 MEMORY MODULE 7300UPG5  pictureSIEMENS SIMATIC S7 MEMORY CARD 32KB 1P6ES7951-0KE00-0AA0 NEW OLD STOCK UNOPENED
$189.5
SIEMENS SIMATIC S7 MEMORY CARD 32KB 1P6ES7951-0KE00-0AA0  NEW OLD STOCK UNOPENED pictureAVL Coyote Memory Programmer Dissolve for 3 Projector (Master Control) Rare Unit
$39.95
AVL Coyote Memory Programmer Dissolve for 3 Projector (Master Control) Rare Unit picture






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