04-07-2009 09:15 AM
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.
Solved! Go to Solution.
04-07-2009 05:34 PM - edited 04-07-2009 05:36 PM
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?
04-08-2009 12:04 AM
Thanks.
My problem is absolutely solved. I din't try RichTextField yet, may be I will try it later.
Thanks again.
01-27-2011 06:07 AM
hey Arif
can u plz post the entire code
thnx in advance
02-13-2013 04:41 PM
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);