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
arif
Posts: 57
Registered: ‎04-07-2009
My Device: 8300
Accepted Solution

Scrollable LabelField

I have to show some information. If information is more than one line it will automatically breaks itself into several lines. For this I created my own CustomLabelField. It works fine. But When I add several CustomLabelFields in a VerticalFieldManager some labels hides below the screen, so I want to scroll it to see those labels, I can't scroll. So I write this method:

 

public boolean isFocusable() { return isFocusable; }

 

By doing this I can scroll. But this time, when a label is focused background is changes its color. I don't want this. I wan't color will remain same and I can scroll. What is the best way to do this?

 

Thanks.

 

Please use plain text.
Developer
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: Scrollable LabelField

[ Edited ]

You realise that you can make a labelField focusable using its constructor, for example:

LabelField my Lab = new LabelField("Test", LabelField.FOCUSABLE);

 

The only way I can think of (and I'm not a UI expert, so there are likely to be other ways), is to override getFocusRect(), and return this as a 0,0,0,0 rectanlge.  I've tried this in 4.2.1, seemed to work.  But might not work for you, and I've no idea of the consequences.

 

public void getFocusRect(XYRect rect) { // super.getFocusRect(rect); rect.width = 0; rect.height = 0; }

 

Just has another thought, have you tried a RichTextField in place of your LabelField?

Message Edited by peter_strange on 04-07-2009 10:36 PM
Please use plain text.
Developer
arif
Posts: 57
Registered: ‎04-07-2009
My Device: 8300

Re: Scrollable LabelField

Thanks.

My problem is absolutely solved. I din't try RichTextField yet, may be I will try it later.

 

Thanks again.

 

Please use plain text.
Contributor
vituvian
Posts: 17
Registered: ‎12-01-2010
My Device: Not Specified

Re: Scrollable LabelField

hey Arif

 

can u plz post the entire code

 

thnx in advance 

Please use plain text.
Regular Contributor
galeb
Posts: 77
Registered: ‎11-03-2009
My Device: 9810 Torch

Re: Scrollable LabelField

Just to add, if you want not to show the blue-cursor (I know some of our clients do not want that), just overwrite drawFocus method.

 

And here is a code snippet, someone aksed:

 

RichTextField  textField = new RichTextField () {
			protected void paint(Graphics graphics) {
				graphics.setColor(Color.WHITE);
				super.paint(graphics);
			}
			protected void drawFocus(Graphics graphics, boolean on) {
		    	// Do nothing
		    }	
		};
		textField.setEditable(false);

 

Please use plain text.