是否可以更改SWT中的工具提示延迟?在Swing中,我通常会使用Tooltip.sharedInstance()中的方法.这似乎在SWT中破裂了.
我使用下面的东西.感谢@Baz :)
public class SwtUtils {
final static int TOOLTIP_HIDE_DELAY = 300; // 0.3s
final static int TOOLTIP_SHOW_DELAY = 1000; // 1.0s
public static void tooltip(final Control c, String tooltipText, String tooltipMessage) {
final ToolTip tip = new ToolTip(c.getShell(), SWT.BALLOON);
tip.setText(tooltipText);
tip.setMessage(tooltipMessage);
tip.setAutoHide(false);
c.addListener(SWT.MouseHover, new Listener() {
public void handleEvent(Event event) {
tip.getDisplay().timerExec(TOOLTIP_SHOW_DELAY, new Runnable() {
public void run() {
tip.setVisible(true);
}
});
}
});
c.addListener(SWT.MouseExit, new Listener() {
public void handleEvent(Event event) {
tip.getDisplay().timerExec(TOOLTIP_HIDE_DELAY, new Runnable() {
public void run() {
tip.setVisible(false);
}
});
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
用法示例: SwtUtils.tooltip(button, "Text", "Message");
| 归档时间: |
|
| 查看次数: |
4933 次 |
| 最近记录: |