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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
shoaibkhan2000
Posts: 49
Registered: ‎08-25-2009

Replace letter with corresponding digit in PEARL and PEARL FLIP

[ Edited ]

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. :smileysad: . 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.

Please use plain text.
Developer
simon_hain
Posts: 13,801
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Replace letter with corresponding digit in PEARL and PEARL FLIP

use Keypad.getAltedChar

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
shoaibkhan2000
Posts: 49
Registered: ‎08-25-2009

Re: Replace letter with corresponding digit in PEARL and PEARL FLIP

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

Please use plain text.
Developer
peter_strange
Posts: 17,702
Registered: ‎07-14-2008

Re: Replace letter with corresponding digit in PEARL and PEARL FLIP

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. 

Please use plain text.
Developer
shoaibkhan2000
Posts: 49
Registered: ‎08-25-2009

Re: Replace letter with corresponding digit in PEARL and PEARL FLIP

I used native blakberry field "net.rim.device.api.ui.component.TextField".

 

I dont have to used "mytextField.setFilter(TextFilter.get(TextFilter.NUMERIC))".

 

I just need to replace the pressed key with its corresponsing integer.

 

Please use plain text.
Developer
peter_strange
Posts: 17,702
Registered: ‎07-14-2008

Re: Replace letter with corresponding digit in PEARL and PEARL FLIP

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?

Please use plain text.
Developer
shoaibkhan2000
Posts: 49
Registered: ‎08-25-2009

Re: Replace letter with corresponding digit in PEARL and PEARL FLIP

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

Please use plain text.
Developer
peter_strange
Posts: 17,702
Registered: ‎07-14-2008

Re: Replace letter with corresponding digit in PEARL and PEARL FLIP

[ Edited ]

"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. 

Please use plain text.