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
New Developer
Posts: 51
Registered: ‎09-15-2009
My Device: Not Specified

Custom TreeField - Strange Behaviour

[ Edited ]

Hi,

 

i use a TreeField to display my items. In the treefieldcallback i do the painting stuff, but the treefield is acting really strange.

Heres the TreeFieldCallback Code:

 

public void drawTreeItem(TreeField treeField, Graphics graphics, int node,
int y, int width, int indent) {
Task item = (Task) treeField.getCookie(node);
int tmp = graphics.getColor();
if (treeField.getCurrentNode() == node) {
graphics.setColor(Color.BLUE);
graphics.fillRect(0, y, Display.getWidth(), treeField.getRowHeight());
if (item.getType() == 0) {
if (treeField.getExpanded(node)) {
graphics.drawBitmap(3, y + 3, 15, 15, minus_icon, 0, 0);
} else {
graphics.drawBitmap(3, y + 3, 15, 15, plus_icon, 0, 0);
}
}
} else {
switch (item.getType()) {
case 1:
graphics.setColor(Color.BEIGE);
graphics.fillRect(0, y, Display.getWidth(), treeField.getRowHeight());
break;
case 0:
graphics.setColor(Color.ROSYBROWN);
graphics.fillRect(0, y, Display.getWidth(), treeField.getRowHeight());
if (treeField.getExpanded(node)) {
graphics.drawBitmap(3, y + 3, 15, 15, minus_icon, 0, 0);
} else {
graphics.drawBitmap(3, y + 3, 15, 15, plus_icon, 0, 0);
}
break;
default:
break;
}
}
graphics.setColor(tmp);
graphics.drawText(item.getTaskname(), indent, y);
}

 

 

Which leeds to the following screen:

select_2.png

select_1.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

As you can see, in the top screenshot, the whole item is focused with a blue background. In the second screen, only a part of the row gets highligthed with the blue color. Which is strange, because the blue rect is painted at the same line of code.

Seems like i cant draw more left then the indent of the row. Is there a way to override this an color the full row?

 

Regards,

Grinarn

Developer
Posts: 88
Registered: ‎05-24-2009
My Device: Not Specified

Re: Custom TreeField - Strange Behaviour

[ Edited ]

I have the same issue, does anyone know how to fix this?

 

EDIT:

 

I think it's due to the clipping rigions during the drawing, however i don't see a method anything in Graphics to expand the clipping region, only to reduce the size thereof.....any clues how to do that?

Contributor
Posts: 14
Registered: ‎06-24-2010
My Device: 8530
My Carrier: Sprint

Re: Custom TreeField - Strange Behaviour

Would you please provide the Task class and its methods?

New Contributor
Posts: 3
Registered: ‎07-30-2010
My Device: Not Specified

Re: Custom TreeField - Strange Behaviour

Hi Grinarn,

 

Can you share the Task Class, please?

Regular Visitor
Posts: 1
Registered: ‎06-11-2010
My Device: 8900
My Carrier: Developer

Re: Custom TreeField - Strange Behaviour

hello ı am begginer blackberry developer. ı try to make tree field menu like your example ı need your task field plase help me. thank you.