I am trying to get the delete key remove characters like a typical backspace key. MyEditField is a subclass of EditField, and the stock EditField contains three methods, protected int backspace( int count, int context )
, public int backspace( int count )
, and protected boolean backspace()
.
MyEditField is set to FILTER_REAL_NUMERIC when instantiated, and I have tried using all the above methods to get the delete key to work. Is it necessary to override the backspace functions to get to work, or am I going to have to write a custom algorithm to get the delete key to remove a character at the end of the string?
I have read the documentation, and I could not find any mention of when the backspace functions will work and when they will not. Also, I know the system (a.k.a. simulator) is registering a key press on the delete since I can print the key code to the console.
I am trying get something more user friendly than having to go through the BB menu to clear the entire field.
Is it necessary to override the backspace functions to get to work
No, it isn't. Just catch the key event and call backspace()
. Smth like:
protected boolean keyChar(char key, int status, int time) {
if (key == Characters.DELETE) {
backspace();
return true;
}
return super.keyChar(key, status, time);
}