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: 984
Registered: ‎02-10-2009
My Device: Not Specified

Re: Stop edit field from wrapping text

Hi Dee,

 

This should work without any problem.

Post your code snippet that causing the error.

 

Regards

Bikas

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Stop edit field from wrapping text

To the original question:

 

You don't need all that complicated code to work.  Rely on the BlackBerry primitives - they are written in the native code and are much more efficient at what they do, not to mention work well together.

 

So, you want a horizontally scrollable EditField which will never go to the second line on its own.  Since Fields do not scroll by themselves (they might, but the documentation does not mention that, so assume they don't), you need something horizontally scrollable.  Hey - isn't HorizontalFieldManager what you are looking for?

 

HorizontalFieldManager myHfm = new HorizontalFieldManager(HorizontalFieldManager.HORIZONTAL_SCROLL);

You may add HORIZONTAL_SCROLLBAR or NO_HORIZONTAL_SCROLLBAR if you like.

Now, since this Manager will let the fields inside have virtually infinite horizontal space (0x3FFFFFFF pixels), your EditField should never wrap on its own.  So a regular EditField will do.  Something like this:

 

EditField myEditField = new EditField("My label: ", "my initial text", EditField.DEFAULT_MAXCHARS, EditField.FOCUSABLE);

 Add the edit field to your Manager and your Manager to your screen (or another Manager which will contain that)

 

myHfm.add(myEditField);

add(myHfm);

 Isn't it simpler?

 

 

Of course, your label will scroll away if you type too many characters.  If you want it to stay, move it out into a LabelField; create an additional, non-scrollable HorizontalFieldManager; add your LabelField and your scrollable HorizontalFieldManager to it; add your EditField to your scrollable HorizontalFieldManager; and finally, add your non-scrollable HorizontalFieldManager to your Screen.

 

That works like a charm, behaves much better on Storm devices (because RIM internal classes are supplied by the OS which has device-specific versions) and is overall faster and easier to debug.

 

Oh, one last thing: if you want your EditField to always be on one line, disable ENTER key processing (which inserts new line and re-layouts your EditField).  Like this:

 

EditField myEditField = new EditField(...) {
    protected boolean keyChar(char c, int status, int time) {
        if (c == Characters.ENTER) {
            return true;
        }
        return super.keyChar(c, status, time);
    }
};

 

 

 

 

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Stop edit field from wrapping text

Since the time I had posted the above reply, I've created a knowledge base article on the topic. The article is much more mature and definitely more thoroughly commented and explained. I've also provided some additional ideas in the comments to it.

 

So for all future readers - here is the link to the article:

Scrollable one-line text input field

I hope it proves useful to you.

 

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

Re: Stop edit field from wrapping text

Hi,

this code really helps me but i want to scoll vertically also i tried a lot but nothing done it only scroll horizontally.

what actually i want is that when text reached to the end of lenghtof textbox then data return from  new line.

 

i think you understand my problem.

 

thanks & regards

         milan

Developer
Posts: 656
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: Stop edit field from wrapping text

I add this style  EditField.NO_NEWLINE  to my edifields to make sure the text stays on one line.  Not sure if this is what you were trying to achieve....just wanted to mention it.


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Stop edit field from wrapping text


milanvishal wrote:

Hi,

this code really helps me but i want to scoll vertically also i tried a lot but nothing done it only scroll horizontally.

what actually i want is that when text reached to the end of lenghtof textbox then data return from  new line.

 

i think you understand my problem.

 

thanks & regards

         milan


Next time, please start a new topic - your post is absolutely contrary to the original goal of this one (the OP here wanted to text not to wrap; you want it to wrap).

 

Anyway, I'm pretty sure you need the following knowledge base article instead:

TextBoxField revisited

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

Re: Stop edit field from wrapping text

ok.
i will take care of it.
& Thanks for reply.
Its really help me.

Thanks & Regards