03-31-2010 04:07 AM - edited 03-31-2010 04:43 AM
Problem is on PEARL and PEARL FLIP (Model that have different keyboard than Curve/Bold and Tour) :
When user press 't' or 'y', I have to display digit '2' in the field.
The Code is:
myField = new TextField(FOCUSABLE)
{
protected boolean keyDown(int keycode, int time)
{
keycode = new Util().mapKeyCode(keycode);
// if the keycode is 5505024 (5505024 is keycode of t and y) return 5505025 (5505025 is keycode of 2)
int key = Keypad.key(keycode);
Dialog.inform("Keycode: " + keycode + "\nKey: " + key + "\nKeycode Map" + Keypad.map(keycode));
// Above line displays Keycode: 5505025, key: 84, Keycode Map: 2
return super.keyDown(keycode, time); //even if I hardcode the keycode on this line it show 't' :( .
}
//Keychar function works fine for Curve/ Bold and Tour. But this is not being called for PEARL and FLIP
protected boolean keyChar(char key, int status, int time)
{
key = new Util().mapKey(key); // replaces t and y with 2
if (new Util().isNumeric(key) || isBackSpace)
{
isBackSpace = false;
return super.keyChar(key, status, time);
}
return false;
}
}
keychar function is not being called in PEARL and PEARL FLIP. and only keyDown is having call. keycode is successfully changed to its corresponding digit in first line of keyDown BUT it shows alphabet and not the digit.
. I need the corresponding DIGIT in the field. Its working fine through keychar in CURVE/ BOLD and TOUR but probleming in PEARL and PEARL FLIP.
Need Urgent HELP.
03-31-2010 04:13 AM
use Keypad.getAltedChar
03-31-2010 04:48 AM
Thanks for the reply.
In which function should I use Keypad.getAltedChar ? It can be used in keyChar function but in case of PEARL and PEARL FLIP keyChar is not getting called.
Please help
03-31-2010 05:11 AM
You appear to be using TextField. I presume this is something that you have written and not javax.microedition.lcdui.TextField?
The easiest way, assuming that TextField extends from something like BasicEditField, is to provide a style that indicates you want the numeric keys only. SOmething like
BasicEditField.FILTER_INTEGER;
See the constructors for BasicEditField for information on how to use the style.
03-31-2010 05:42 AM
I used native blakberry field "net.rim.device.api.ui.component.TextField".
I dont have to used "mytextField.setFilter(TextFilter.get(TextFilter.N
I just need to replace the pressed key with its corresponsing integer.
03-31-2010 05:58 AM
AFAIK, TextField is not a published class and it gets dropped in later OS's. I recommend that you change your definitions to use something else, like BasicEditField.
In my experience the SureType devices do not go through keyChar like the the QWERTY devices. So converting it as you seem to be trying to do will be difficult, and I am not aware of a 'clean' way to do it. Can you explain why you can not use the constructor to set the Filter, or set the Filter yourself?
03-31-2010 07:27 AM
By using setFilter to NUMERIC it shows 123 indicator on the top right and i have a button at the same postion (top right). This 123 indicator comes on top of my button. To avoid this I used this approach and it is working on BOLD, CURVE and TOUR simulator. Giving problem in PEARL and PEARL FLIP
03-31-2010 07:54 AM - edited 03-31-2010 07:58 AM
"it shows 123 indicator on the top right and I have a button at the same position (top right)."
Which doesn't matter since they are entering text in another position anyway.
Personally I would not worry about that indication, it is no big deal and is a good indication.
But if you are really and truly worried about it, the only way I know that you can do this is to use a FieldChanged listener. You will get notified in there when a character is chosen, you can check what the character is and substitute. However I suspect from a user perspective, the 123 indicator is much less invasive.