Reputation: 133
viewer.getControl().addListener(SWT.MeasureItem, new Listener() {
@Override
public void handleEvent(Event event) {
TreeItem item = (TreeItem)event.item;
String text = getText(item, event.index);
Point size = event.gc.textExtent(text);
event.width = size.x;
event.height = Math.max(event.height, size.y);
}
});
In the above code snippet the listener is added but it is not coming to handleEvent method at all.
Upvotes: 0
Views: 415
Reputation: 111142
For TreeViewer do not try to add Listeners as that will interfere with the operation of the viewer.
To draw the lines yourself use a Label Provider which extends OwnerDrawLabelProvider
and implement the measure
, erase
and paint
methods.
Upvotes: 1