BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 11-06-2006, 07:59 PM   #1
forcedfx
Knows Where the Search Button Is
 
Join Date: Nov 2006
Model: 8310
Carrier: AT&T (formerly Cingular)
Posts: 47
Default Trying to restrict characters entered into a BasicEditField control

Please Login to Remove!

I've been racking my brain trying to figure this out for two days now.

I have a BasicEditField buit into a MainScreen that is used for entering the MAC address of a network adapter.

The field is only supposed to accept the characters 0-9, a-f, and A-F. What I want to do is grab each character as the user enters it and decide whether to keep it or discard it. None of the pre-defined Filters will work for this field. Is there a way to create my own filter? That would be ideal.

Anyway, I tried overriding the keyChar, keyDown, and keyControl events but none of them seem to give me what I want. The keyChar event is not being called when I enter letters or numbers into the BasicEditField, but when I press the backspace key it does work. And I don't think keyDown and keyControl are what I need.

All of the documentation I've read on this event seems to state that it will report each character that is entered.

I've also tried using a FieldChangeListener to examine the text every time it changes, but it's a cumbersome process and still doesn't work the way I want it to.
Offline  
Old 11-07-2006, 01:53 PM   #2
jbartel
Knows Where the Search Button Is
 
Join Date: Sep 2004
Posts: 17
Default

Have you tried using a net.rim.device.api.ui.text.HexadecimalTextFilter? It does not allow lower case a-f but will convert the lower case ones to uppercase as the user types them.

BasicEditField has a setFilter method to set a TextFilter for the field. If the built-in HexadecimalTextFilter does not meet your needs you can extends the TextFilter class to create a custom filter that does whatever you want it to do.
Offline  
Old 11-07-2006, 02:43 PM   #3
forcedfx
Knows Where the Search Button Is
 
Join Date: Nov 2006
Model: 8310
Carrier: AT&T (formerly Cingular)
Posts: 47
Default

I tried using the hex filter but it does not seem to work correctly. It filters out all numbers and allows me to enter letters, such as, "S" when it should not.

Do you know where I can find resources on the custom filter? I have another text field that can only allow certain characters so I would be needing it there as well. If I can define my own filter I can finally move on to another part of this project. I tried googling the custom text filter but all I found were definitions which didn't really help me, unfortunately.
Offline  
Old 08-10-2007, 04:37 AM   #4
rock_win
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
Default

hi

any luck making custom filters......... i'm also stuck in a similar situation and would appreciate help on the subject.
Offline  
Old 08-10-2007, 08:39 AM   #5
bemshaswing
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Default

have you tried overriding keyCharUnhandled as well? That might help
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


55 LB Electric Lift Magnet Electromagnet Solenoid Holding 57mm Robotics 12v 24v picture

55 LB Electric Lift Magnet Electromagnet Solenoid Holding 57mm Robotics 12v 24v

$12.50



55 LB Electric Lift Magnet Electromagnet Solenoid Holding 40mm picture

55 LB Electric Lift Magnet Electromagnet Solenoid Holding 40mm

$13.99



176 LB (80kg) Electric Lifting Magnet Electromagnet Solenoid Lift Holding 65mm picture

176 LB (80kg) Electric Lifting Magnet Electromagnet Solenoid Lift Holding 65mm

$27.99



12V DC Lifting Holding Magnet Electromagnet Solenoid Electric Magnet 800N picture

12V DC Lifting Holding Magnet Electromagnet Solenoid Electric Magnet 800N

$23.60



US Stock 176LB 80kg Lifting Magnet Electromagnet Solenoid Lift Holding 65mm 12V picture

US Stock 176LB 80kg Lifting Magnet Electromagnet Solenoid Lift Holding 65mm 12V

$36.09



DC 24V 400N Electric Lifting Magnet Electromagnet Solenoid Lift Holding picture

DC 24V 400N Electric Lifting Magnet Electromagnet Solenoid Lift Holding

$17.35







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