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: 18
Registered: ‎01-27-2010
My Device: Curve 8330
My Carrier: Verizon
Accepted Solution

How to get RichTextField to wrap

[ Edited ]

Good Afternon fellow developers:

 

I was wondering if someone can help me with my issue. I trying to get the Text in my RichTextField to wrap when I place it in a verticalManager. Basically, if I have:

 

super(NO_VERTICAL_SCROLL);

 

 

lblUserText

 

= new RichTextField("Please select one of the following options below:");

 

 

 

VerticalFieldManager vfm =

new VerticalFieldManager()

 

vfm.add(lblUserText)

add(vfm);

 

The text in the RichTextField wraps to the next line just fine. But if I do the following:

 

 

 

 

 

 

super

(NO_VERTICAL_SCROLL);

 

lblUserText

= new RichTextField("Please select one of the following options below:");

 

 

VerticalFieldManager vfm =

new

VerticalFieldManager()

{

 

   protected void paint(Graphics graphics)

{

   graphics.setBackgroundColor(0xE8E691);

   graphics.clear();

   graphics.setColor(0x000000);

   graphics.drawText(lblUserText.getText(), 0,0);

 }

};

 

The text doesn't wrap. It goes off horizontally cutting off the "below:" text. Even if I say:

super(NO_VERTICAL_SCROLL | NO_HORIZONTAL_SCROLL);

it doesn't work. What am I doing wrong?

 

 

 

 

 

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to get RichTextField to wrap

Nothing.

 

If you want to take over painting the RichTextField yourself, then you have to implement the wrapping yourself.  drawText paints one line (and one line only).  So you have figure out where the lines break, paint the text on one line, move the "y" down and paint the next line with the next text (and so on). 

Developer
Posts: 18
Registered: ‎01-27-2010
My Device: Curve 8330
My Carrier: Verizon

Re: How to get RichTextField to wrap

Thanks for the response.

Developer
Posts: 62
Registered: ‎10-29-2008
My Device: 9800
My Carrier: Rogers

Re: How to get RichTextField to wrap

I wonder: If you paint the text for an ActiveRichTextField, does that lose any sort of auto recognition? i.e. will it still recognize URLS and phone numbers?

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to get RichTextField to wrap

I would expect that it will loose any hotlink capabilitiy, though it might get very confused about this.  I wouldn't recommend tryying it!