简体   繁体   English

鼠标悬停在列表项上时如何显示工具提示?

[英]How to display a tooltip when mouse is hovered on a list item?

I want to display tooltip text whenever I hover the mouse on SWT List.每当我将鼠标悬停在 SWT 列表上时,我都想显示工具提示文本。 When I was surfing on the internet, I found a listener MouseTrackListner and to override mouseHover() method.当我在网上冲浪时,我发现了一个监听器MouseTrackListner并覆盖了mouseHover()方法。

But how will I get the text of the list when I hover on any item in the list?但是,当我将鼠标悬停在列表中的任何项目上时,如何获取列表的文本?

The SWT List does not have the concept of a tooltip per item. SWT List没有每个项目的工具提示的概念。 Only a tooltip for the entire control can be set.只能设置整个控件的工具提示。 And the position of that tooltip is not related to the currently hovered over or selected item.并且该工具提示的位置与当前悬停或选定的项目无关。

As Greg suggested, you should use a TableViewer and use the ColumnViewerToolTipSupport .正如Greg建议的那样,您应该使用TableViewer并使用ColumnViewerToolTipSupport

See here for more information about TableViewer tooltips: ColumnViewerTooltipSupport in SWT有关 TableViewer 工具提示的更多信息,请参见此处: SWT 中的 ColumnViewerTooltipSupport

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM