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
Developer
Posts: 139
Registered: ‎02-23-2012
My Device: Blackberry bold
My Carrier: Vodafone India
Accepted Solution

Modify Edit Field

hi! All

 

how can we just restrict a Edit Field to a width (lets say 70) and if user enters anything that is exceeding the width then the text should be scroll automatically back to make space for user to enter some more text...

 

How to achieve this?

 

warm regards
Mohammed Aziz
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Modify Edit Field

if you enter "editfield scrolling" into the searchbox you get plenty of results.
i guess most link to this KB article:
http://supportforums.blackberry.com/t5/Java-Development/Sample-Code-Scrollable-one-line-text-input-f...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Modify Edit Field

"the text should be scroll automatically back"

 

What does this mean?  What will the user see?

 

It is possible in a FieldChangeListener to listen for the number of characters entered and when it exceeds a limit, it can truncate this and update the Field with the truncated value.  However if you try this you will find that you have be very careful about the current cursor position, making sure that the user's insert point is respected. 

Developer
Posts: 139
Registered: ‎02-23-2012
My Device: Blackberry bold
My Carrier: Vodafone India

Re: Modify Edit Field

usually when the entered text crosses the limit (width) , the text will appear automatically on next line.

What I need is when text touches the end point the curser should be at the end so that the user can see what he/she is entering but the prevoius text should be get hidden not truncated.....

hope you got my point
warm regards
Mohammed Aziz
Developer
Posts: 139
Registered: ‎02-23-2012
My Device: Blackberry bold
My Carrier: Vodafone India

Re: Modify Edit Field

What I want is the functionality that we can see on editing PATH in Environment variable on our Windows OS
warm regards
Mohammed Aziz
Developer
Posts: 139
Registered: ‎02-23-2012
My Device: Blackberry bold
My Carrier: Vodafone India

Re: Modify Edit Field

this is what I want

public class OneLineTextField extends HorizontalFieldManager {
private EditField editField;

public OneLineTextField(String label, String initialValue, int maxChars, long style) {
super(HORIZONTAL_SCROLL);
editField = new EditField(label, initialValue, maxChars, style | EditField.NO_NEWLINE | EditField.FOCUSABLE | EditField.EDITABLE);
add(editField);
}

public String getText() {
return editField.getText();
}
}

Thanks simon and peter for your replies..
warm regards
Mohammed Aziz