02-09-2011 11:30 AM
I’ve been trying all day to get a plain simple input box, nothing fancy,
I tried using
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!
02-09-2011 11:52 AM
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().
02-09-2011 12:09 PM
All on the constructors....
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.
02-09-2011 12:35 PM
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?
02-10-2011 05:19 AM
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
02-10-2011 09:38 AM
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...
02-10-2011 12:38 PM
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.
02-10-2011 12:40 PM
If you plan on doing much BB development, you and paint will become very close . It's good practice for other, more complicated customizations you'll probably end up doing.