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: 17
Registered: ‎03-17-2009
My Device: Not Specified

BasicEditField can't edit

Hi,

 

I have a problem to input text with BasicEditField. I'm  using BB JDE 4.2.1.

I have a  MainScreen Class

 

public class ScreenContent extends MainScreen

 

 

In the constructor of the class I'm adding some Checkboxfields and after that the BasicEditField

 

contentField= new BasicEditField("Label:", "content", 255, BasicEditField.EDITABLE);
add(
contentField);

 

Using the simulator I can't edit the BasicEditField. What is the proper way to implement some input text field that can be edit?

Developer
Posts: 17
Registered: ‎03-17-2009
My Device: Not Specified

Re: BasicEditField can't edit

 

I found why can't capture text with BasicEditField.

In the screen class I'm overriding the method

 

public boolean keyChar(char key, int status, int time)

 

thats the reason.  If I remove the overriding method is working properly. I'm using this overriding because when is pressed the Escape button I receive the exception: java.lang.RuntimeException: Attempt to push Screen while already displayed!,

so with keyChar I was catching the Characters.ESCAPE and displaying the previous screen.

 

Overriding keyChar to prevent java.lang.RuntimeException: Attempt to push Screen while already displayed! works for me until I don't need to capture text input. How can I solve this?

 

 

 

Highlighted
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: BasicEditField can't edit

[ Edited ]

The root issue is your exception - obviously you have a bug in your code and you took the questionable method of solving the issue by not closing the screen?

 

When you override keyChar(), you have to redelegate any keystrokes that you do not consume.

 

So, if "eating" the escape key is the correct thing to do, you return true (since you are handling the event) when you see the ESC key, and return "false" if it is not the ESC key.