12-09-2009 11:39 AM
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);
Using the simulator I can't edit the BasicEditField. What is the proper way to implement some input text field that can be edit?
12-09-2009 01:19 PM
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?
12-09-2009 04:12 PM - edited 12-09-2009 04:13 PM
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.