ColumnViewerTooltipSupport in SWT

↘锁芯ラ 提交于 2019-12-07 19:09:21

问题


What is the exact use of ColumnViewerTooltipSupport? I know that it provides tooltip support for ColumnViewers but does it mean that it provides tooltip for treeViewers? How can I use this feature to provide tooltip support individually different tooltips for my each tree item when the mouse hovers over each item? Do I require a MouseListener for this or does the ColumnViewerTooltipSupport class provide it by default? Can someone please help me out here as I'm relatively new to SWT concepts.

My tooltip has multiple lines, How can I wrap the text and display it neatly? It seems like ColumnViewerToolTipSupport class does not wrap the tooltip text if the text is too long. I would like to use a tooltip window with a vertical scroll bar just like the InformationControl Windows in eclipse? If something like eclipse is not possible then just a tooltip window with wrapped up text.

Please show me an example snippet?


回答1:


ColumnViewerToolTipSupport adds support for individual tooltips to TableViewer and TreeViewer (and other ColumnViewers), you enable this using:

ColumnViewerToolTipSupport.enableFor(viewer);

The support expects that the label provider(s) for the viewer are based on CellLabelProvider (or one of its subclasses).

CellLabelProvider has getToolTipImage, getToolTipText, getToolTipBackgroundColor, getToolTipForegroundColor, getToolTipFont and getToolTipShift methods that you can override to control the tooltips.

Note: All this is JFace code not pure SWT



来源:https://stackoverflow.com/questions/23105095/columnviewertooltipsupport-in-swt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!