BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-20-2010, 05:27 PM   #1 (permalink)
New Member
 
Join Date: Aug 2010
Model: 8900
PIN: N/A
Carrier: o2
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default keyChar

Please Login to Remove!

Hi guys. I'm very much new to BB apps and know a little Java. why can I not check for multiple keys presses. the basic code detects the "enter" key, and does what it is supposed to do, but will not check the next (or it works but my comparison statement is wrong). I've tried alsorts but nothing works. I'm trying this on the default simulator that comes with the latest download of Eclipse and the blackberry JDE.
Code:
tfSatFat=new BasicEditField(BasicEditField.NO_NEWLINE){
            public boolean keyChar( char key, int status, int time ) {
            	//Dialog.alert(key);
                //System.out.println("KeyChar: " + key);
               if (key == Characters.ENTER ) {
                	//do something
               }
               else if (key == '4') {
                //do something else
              //but in reality we never enter here.
               }
               return super.keyChar(key,status,time);
           }
        };
I have looked everywhere and not seen an answer to my question but several people have had the similar issue.

Thanks
Offline  
Old 08-20-2010, 06:43 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Use ...

(key == Characters.DIGIT_FOUR)
Offline  
Old 08-21-2010, 03:53 AM   #3 (permalink)
New Member
 
Join Date: Aug 2010
Model: 8900
PIN: N/A
Carrier: o2
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply. I'm trying to run the code in debug mode, and the only time it enters the keyChar call back is when i press the "enter" key, or the "delete" key, not a letter or number key.

what argument should my
Code:
SatFat=new BasicEditField(what_here_?){
have?


what I'm doing is trying to allow people to enter non-whole numbers (5.6) in the box, so as I have read, i need to test the type of key pressed and ignore ones like normal characters (aq,w,e,r,t) etc.

I'm sure this is a very trivial thing?!?!?

thanks.
Offline  
Old 08-21-2010, 09:48 AM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Set the filter to NumericTextFilter.

When you instantiate the text filter, set the ALLOW_DECIMAL property.
Offline  
Old 08-21-2010, 03:44 PM   #5 (permalink)
New Member
 
Join Date: Aug 2010
Model: 8900
PIN: N/A
Carrier: o2
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I reckon that got it.Thanks very much. The code I used was about:

Code:
public NumericTextFilter numFilter = new NumericTextFilter(NumericTextFilter.ALLOW_DECIMAL);
EditField myEdField;
myEdField.setFilter(numFilter);
Legend!!!!!
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Genuine OEM IBM Selectric I and II Typewriter Typing Elements Balls
$19.95
Genuine OEM IBM Selectric I and II Typewriter Typing Elements Balls pictureLot of 5 New OEM Genuine Ricoh IBM 39V3204 Toner Cartridge SEALED
$305.27
Lot of 5 New OEM Genuine Ricoh IBM 39V3204 Toner Cartridge SEALED pictureLot of 4 New OEM IBM 1372475 Pageprinter 3130 Fuser 100v
$9.34
Lot of 4 New OEM IBM 1372475 Pageprinter 3130 Fuser 100v pictureLot of 7 New OEM IBM 1372476 3130 Pageprinter Cleaning Kit
$0.89
Lot of 7 New OEM IBM 1372476 3130 Pageprinter Cleaning Kit  pictureLot of 4 New OEM IBM 44D7279 Infoprint 4100 toner cartridge
$0.89
Lot of 4 New OEM IBM 44D7279 Infoprint 4100 toner cartridge picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.