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
Contributor
forumaic
Posts: 30
Registered: ‎10-07-2011
My Device: developer
My Carrier: HÍ

Re: focus problem with custom text field

Hello arkadyz,

 

I added:

public NumericTextField(long style) {
    super(style);
}

 in the NumericTextField class, and in the code:

long style = EditField.FILTER_REAL_NUMERIC | EditField.NO_NEWLINE | EditField.CONSUME_INPUT ;

_textFieldFrom = new NumericTextField(style);

 It accepts only real number, but:

1. Not working NO_NEWLINE (number goes into another line)

2. How to catch unsupported characters in the field? Have I do it in NumericTextField class (f.e. 123....12.32..), you can put more than one time comma, that is not acceptable for the real number

3. What I have to call to activate blue cursor in my textfield (same type of cursor, then you open an application in the beginning)?

 

I will very appreciate for your help.

Thanks in advance.

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

Re: focus problem with custom text field

1) NO_NEWLINE doesn't allow new lines in the text. The field may still wrap around if the text inside is too long. For some ideas on how to replace wraparound with scrolling, look here:

Scrollable one-line text input field

2) For finer control over the input, override keyChar (and disregard filters).

3) I'm not sure what kind of cursor do you need. All my text fields have a cursor and I don't see anything in your code that would somehow conceal 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.
Contributor
forumaic
Posts: 30
Registered: ‎10-07-2011
My Device: developer
My Carrier: HÍ

Re: focus problem with custom text field

Hello again,

with question 2 I have managed to solve it. Thanks a lot for your help.

with question 1 still have problems. I need that code will allows only one line, I don't need any scrolling. NO_NEWLINE dosn't do trick. How I could fix it? Should set maxDigits that fits to one line?

with question 3 I still working, hoping to get it to work soon.

 

One more question. How should I draw nice borders around my textField?

 

Thanks again.

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

Re: focus problem with custom text field

The same article I quoted talks about and even shows some example of drawing a border around the text - check the comments.

----------------------------------------------------------
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.
Contributor
forumaic
Posts: 30
Registered: ‎10-07-2011
My Device: developer
My Carrier: HÍ

Re: focus problem with custom text field

Hello arkadyz again,

again about allowing only real number in the field. If I leaving 

long style = EditField.FILTER_REAL_NUMERIC;

 I am allow to insert number using keypad, not matters if you using "ALT" button if not, the result in textField is the same in bove ways: "S" and "ALT+S" -> 4.

If I disable 

EditField.FILTER_REAL_NUMERIC

and override keyChar method, it allows only insert numbers then you using "ALT", f.e. "ALT+S" -> 4, then you click "S" nothing happens.

 

It seems logical and everything is ok. But is it a way somehow to implement keyChar method (override it) to allow bove input number options: with and without "ALT"?

 

Thanks in advance.

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

Re: focus problem with custom text field

You have full control of what you allow or not allow there in your keyChar - if the ALTed key would be a number, insert that number. Keypad.getAltedChar(c) is your friend here :smileyhappy:.

Don't forget - you can call super.keyChar with altered paremeters :smileywink:.

----------------------------------------------------------
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.
Contributor
forumaic
Posts: 30
Registered: ‎10-07-2011
My Device: developer
My Carrier: HÍ

Re: focus problem with custom text field

could you provide with an example?

I read about Keypad.getAltedChar(ch) and trying in my overrided method keyChar to do this

if (CharacterUtilities.isDigit(ch) || Keypad.getAltedChar(ch) == ch)

 but no behaviour as I expecting, you still need to use "ALT" button.

 

Could you explain what I am doing wrong, or maybe with the working example.

 

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

Re: focus problem with custom text field

Try this:

if (CharacterUtilities.isDigit(ch) || CharacterUtilities.isDigit(ch = Keypad.getAltedChar(ch)))

and see if it works better. See the difference?

----------------------------------------------------------
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.
Contributor
forumaic
Posts: 30
Registered: ‎10-07-2011
My Device: developer
My Carrier: HÍ

Re: focus problem with custom text field

thanks man, its working.

Please use plain text.