Greetings fellow Stackoverflownians!

I am building an Eclipse RCP application, and have come across an issue:

I want to set a tooltip text on a TreeItem, but this class does not inherit Control, which is the class that has the setTooltipText

EDIT: It seems that jface is supposed to take care of this seamlessly, through a LabelProvider. I am using a ColumnLabelProvider with getToolTipText method on each column of a complex TreeViewer, but it isn't working. I wonder why...

有帮助吗?

解决方案 2

With TreeViewer use

ColumnViewerToolTipSupport.enableFor(viewer);

Use a label provider derived for CellLabelProvider or one of it subclasses and override getToolTipText (there are also several other methods to control the font, time out and the like).

其他提示

The probleme here is that you use the SWT-Tree. You should use a TreeViewer (JFace) which wraps the tree and gives you more sophisticated options. Inside the label provider of the TreeViewer, you can define your tooltips.

Learn more about viewers here and here

An code example (tool tip) is here

I strongly recommend you to use the viewers!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top