BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-29-2007, 09:12 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation what am i doing wrong ??

Please Login to Remove!

When i run my application and press any keys nothing happens.I want to capture the key events.what am i doing wrong.

Code:
public class Panic_Entry extends MainScreen implements KeyListener {
    
    public Panic_Entry() {
        super();
        setTitle("Hello");
        Application.getApplication().addKeyListener(this);
        //super.addKeyListener();
    }
    public boolean keyChar(char key, int status, int time) {
        boolean retval = false;
        switch(key) {
            case Characters.ESCAPE:
                Dialog.alert("Escape");
                break;
            case Characters.DELETE:
                Dialog.alert("Delete");
                break;
            default:
                retval = super.keyChar(key,status,time);
        }
        return retval;
    }
    public boolean keyStatus(int keycode, int time) {return true; }
    public boolean keyRepeat(int keycode, int time) {return true;  }
    public boolean keyUp(int keycode, int time) {return true;  }
    public boolean keyDown(int keycode, int time) {return true;  }
}
__________________
Thanks
Meenal
Offline  
Old 08-29-2007, 09:25 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

try this:

Code:
public class Panic_Entry extends MainScreen{
    
    public Panic_Entry() {
        super();
        setTitle("Hello");
    }
    
    public boolean keyChar(char key, int status, int time) {
        boolean retval = false;
        switch(key) {
            case Characters.ESCAPE:
                Dialog.alert("Escape");
                break;
            case Characters.DELETE:
                Dialog.alert("Delete");
                break;
            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 08-30-2007, 01:22 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default one more problem !!!

thx..it worked.

There is one pecular thing tht i have encountered and dont know how to solve it.it has occured atleast in pearl simulator.
when i click on the trackball and then on menu bittuon... two menus open up and both have the focus.Now if i click on the trackwheel,the simulator hangs up.i then have to exit the simulator altogether.
In my program i havent defined any menu items at all.
What exactly is the problem here and how can i solve it.Suggestion.The code is same as above with the suggested corrections by jfisher. I am also attaching a snapshot.

Could anyone suggest how i can handle it.

One more Q:
Can an application listen to keypad events when it is in the background?
Attached Images
File Type: png 8100.png (1.5 KB, 5 views)
__________________
Thanks
Meenal

Last edited by Meenal : 08-30-2007 at 02:34 AM.
Offline  
Old 08-30-2007, 10:25 AM   #4 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

not sure about your first problem, that is weird. but to answer your one more Q, no an app can't listen to keypad events in the background, they're intercepted by whatever app is in the foreground
Offline  
Old 08-30-2007, 11:45 PM   #5 (permalink)
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Meenal View Post
thx..it worked.

There is one pecular thing tht i have encountered and dont know how to solve it.it has occured atleast in pearl simulator.
when i click on the trackball and then on menu bittuon... two menus open up and both have the focus.Now if i click on the trackwheel,the simulator hangs up.i then have to exit the simulator altogether.
In my program i havent defined any menu items at all.
What exactly is the problem here and how can i solve it.Suggestion.The code is same as above with the suggested corrections by jfisher. I am also attaching a snapshot.

Could anyone suggest how i can handle it.

One more Q:
Can an application listen to keypad events when it is in the background?

Can you just clarify one thing whether two menus popping out at the same time happened once or every time the application is launched in pearl simulator.
Offline  
Old 08-31-2007, 12:23 AM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

It happens everytime i launch te application in the simulator.
__________________
Thanks
Meenal
Offline  
Old 08-31-2007, 01:10 AM   #7 (permalink)
Thumbs Must Hurt
 
Rose's Avatar
 
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Meenal View Post
It happens everytime i launch te application in the simulator.
Try overwriting the make menu and see it happens again.
Offline  
Old 08-31-2007, 01:46 AM   #8 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Location: India
Model: 8700g
Carrier: Airtel
Posts: 117
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question

Is there no way by which i can make my application listen to the keys pressed events? like for example I want to bring my application to foreground on pressing certain key combinbations. Is thier no way an application can listen to key events?
__________________
Thanks
Meenal
Offline  
Old 08-31-2007, 03:13 AM   #9 (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

not from the background no.
__________________
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  
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.