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
Developer
Posts: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: How to disable the Call button and call end button.

Can you paste the code you are trying with.

 

Regards

Bikas

New Developer
Posts: 20
Registered: ‎07-23-2008
My Device: Not Specified

Re: How to disable the Call button and call end button.

[ Edited ]

hi,

In case of MainScreen there is no need of this.addKeyListener(this) .and this may through exception.it implecitly implements keyListener as far as i know.Bikas's code works without adding keyListener to mainscreen. it works fine only if ur application in foreground and ur currentscreen is the screen which is listening the keys.

Message Edited by neeraj on 09-29-2009 04:02 AM
Message Edited by neeraj on 09-29-2009 04:06 AM
New Developer
Posts: 20
Registered: ‎07-23-2008
My Device: Not Specified

Re: How to disable the Call button and call end button.

may be when u r pressing the key ur screen is not foreground.
Developer
Posts: 19,621
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to disable the Call button and call end button.

"In case of MainScreen there is no need of this.addKeyListener(this)", good point neeraj, OP I think you can ignore this comment in my post.
Developer
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: How to disable the Call button and call end button.

Hi i could'nt disable the buttons but could handle it by overiding the deactivate() method and i snooze the alrm when green or red clicked...
New Developer
Posts: 24
Registered: ‎07-20-2009
My Device: Not Specified

Re: How to disable the Call button and call end button.

One suggestion - like neeraj wrote, when you expect the user to press the red/green key, make sure your application is
1. in foreground
2. not with black screen
In one of my application I'm able to catch those keys properly only if the application is visible, once the screen gets black (BB "screen saver"), my screen is no longer receiving these keyDown events and therefore when pressing red key the home screen appears...
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: How to disable the Call button and call end button.

regarding Key codes...

I prefer doing it this way:

 

 

/** * Overridden to capture SEND and END keys * @param aKeyCode * @param aTime * @return */ public boolean keyDown(int aKeyCode, int aTime) { if (Keypad.key(aKeyCode) == Keypad.KEY_SEND) { return true; // always consume SEND key } else if(Keypad.key(aKeyCode) == Keypad.KEY_END || Keypad.key(aKeyCode) == Keypad.KEY_ESCAPE) { // close screen or whatever //close(); return true; // consume } return super.keyDown(aKeyCode, aTime); }

Isn't that a bit nicer :smileyhappy: ?

And you can easily expand the logic without asking for key codes :smileywink:

 

 



"Listen carefully, I shall say this only once"