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.

inside custom component

Java Development

Reply
Regular Contributor
benabouttown
Posts: 82
Registered: ‎10-28-2010
My Device: Not Specified

How to get a plain simple Input Box

 

I’ve been trying all day to get a plain simple input box, nothing fancy,

  • no spell checker,
  • no auto suggestion,
  • no auto complete.
  • no select and highlight, underline or cut and paste.

 

I tried using

  •             BasicEditField
  •             EditField

 

But with both of these, one or more of the fancy extra’s appears.

 

Has anyone got a plain simple input box? Is there one in the API ?

 

All I am looking to do is be able to type in the input box some plain text. Can anyone advise?

 

Using API 6.0

 

any points would help a lot!

 

Thanks

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: How to get a plain simple Input Box

How do you create those edit fields? Have you taken a look at various constructors, especially those including long style parameter? Have you tried Field.NON_SPELLCHECKABLE flag? TextField.NO_COMPLEX_INPUT? Other interesting flags?

 

Also consider overriding public boolean isSelectable().

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Regular Contributor
benabouttown
Posts: 82
Registered: ‎10-28-2010
My Device: Not Specified

Re: How to get a plain simple Input Box

 

All on the constructors....

TextField.NO_LEARNING |

TextField.NON_SPELLCHECKABLE |

TextField.CONSUME_INPUT

 

although the NO_COMPLEX_INPUT stops its from doing spell check, it now displays a number keypad. and the keyChar event doesn't fire.

 

there must be away of tell the system not to give me auto correct, spell check, and all the other stuff.

Please use plain text.
Developer
jprofitt
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: How to get a plain simple Input Box

Out of curiousity, what is the end result you want from this? Maybe we can suggest another way to do what you're trying to do. What is the input box going to be used for? Also, what are you needing keyChar for?

Please use plain text.
Regular Contributor
benabouttown
Posts: 82
Registered: ‎10-28-2010
My Device: Not Specified

Re: How to get a plain simple Input Box

Hi the end result is a box that accept singel characters and stores them in a array list.

 

The characters need to be uppercase, and need to cross check against a list of characters that are allowed.

 

So if you are allowed to enter the character A,D,G,T then only these are accepted, thus why i need to keyChar function to work, thus i need the extras (Spell check, auto correct, auto complete, etc) to turn off

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: How to get a plain simple Input Box

If you need that level of control it would be easier to extend Field and do all of your input and painting yourself. I have a feeling that you are able to do that. Just don't forget to return the coordinates of your "cursor" in getFocusRect().

Another consideration (might not be relevant in your case) - if you want to allow setFont on your custom Field, override it to call super.setFont followed by updateLayout.

 

If you do the painting yourself, you will be able to easily paint borders, custom background etc.

 

Word-wrap would normally be your worst enemy, but it looks like your specific situation does not care about that...

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Regular Contributor
benabouttown
Posts: 82
Registered: ‎10-28-2010
My Device: Not Specified

Re: How to get a plain simple Input Box

create my own field ??

 

I see a whole load of hurt coming my way ... the paint() method is going to be the tricky one.

 

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: How to get a plain simple Input Box

paint() in your case is relatively easy:

Draw text using drawText (duh!), have the vertical position always as 0, draw the text before the cursor at horizontal position 0, get its advance, draw one letter after the cursor with underlined font at the position of the previous text advance, get advance of that underlined letter, add it to the advance of pre-cursor text and draw the rest of the post-cursor text starting from this position. If there is no post-cursor text, draw a single white space underlined instead.

 

Like I said, if you don't care for word-wrap (which you apparently shouldn't - such requirements are more suitable to all kinds of product code fields etc. which should stay on one line) this is the easier way.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
jprofitt
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: How to get a plain simple Input Box

If you plan on doing much BB development, you and paint will become very close :smileywink:. It's good practice for other, more complicated customizations you'll probably end up doing.

Please use plain text.