是否可以更改SWT中的工具提示延迟? 在Swing中,我通常会使用Tooltip.sharedInstance()中的方法。这似乎打破了SWT。设置SWT工具提示延迟
1
A
回答
2
不,据我所知。工具提示与底层本地系统的工具提示紧密结合,因此您坚持了自己的行为。
但还有另一种方法,你将不得不自己实现工具提示。用这种方法你可以创建非常复杂的工具提示。
class TooltipHandler {
Shell tipShell;
public TooltipHandler(Shell parent) {
tipShell = new Shell(parent, SWT.TOOL | SWT.ON_TOP);
<your components>
tipShell.pack();
tipShell.setVisible(false);
}
public void showTooltip(int x, int y) {
tipShell.setLocation(x, y);
tipShell.setVisible(true);
}
public void hideTooltip() {
tipShell.setVisible(false);
}
}
3
您可以使用下列内容:
ToolTip tip = new ToolTip(shell, SWT.BALLOON | SWT.ICON_INFORMATION);
tip.setText("Title");
tip.setMessage("Message");
tip.setAutoHide(false);
然后,每当你要显示它,使用tip.setVisible(true)
和启动一个定时器,在指定的时间后会调用tip.setVisible(false)
。
tip.setAutoHide(false)
强制提示留下,直到您致电tip.setVisible(false)
。
5
我使用类似下面的东西。由于@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);
}
});
}
});
}
}
用例:SwtUtils.tooltip(button, "Text", "Message");
相关问题
- 1. jquery工具提示延迟显示
- 2. 显示工具提示前的延迟
- 3. NSStatusItem工具提示 - 更改延迟
- 4. jQuery UI工具提示延迟加载
- 5. 有延迟的gwt工具提示
- 6. Flex 3:errorstring工具提示延迟?
- 7. 延迟检票组件工具提示
- 8. PySide:即时工具提示(在显示工具提示前不延迟)
- 9. 如何在Flex中只设置一个组件的工具提示延迟?
- 10. 设置延迟
- 11. NSImageCell:设置工具提示
- 12. nvd3禁用上显示工具提示延迟/隐藏
- 13. Shell_NotifyIcon:气球工具提示10秒后示出延迟
- 14. jQuery UI工具提示加载和延迟显示
- 15. 如何实现延迟显示twipsy工具提示
- 16. 的jquery - 延迟加载 - 设置延迟
- 17. SWT中的工具提示能见度
- 18. Datagridview单元格工具提示延迟时间
- 19. MS图表:可能会减少工具提示延迟?
- 20. 如何减少工具提示文本弹出延迟?
- 21. jQuery UI工具提示延迟没有效果
- 22. visual studio 2010智能感知工具提示延迟
- 23. Chart.js(折线图)工具提示持续时间/延迟
- 24. 有没有办法在eclipse工具提示中添加延迟?
- 25. Highstock v3.0如何禁用工具提示超时/延迟
- 26. 每个对象的可可工具提示延迟?
- 27. Twitter引导工具提示插件中的数据延迟
- 28. Jquery UI工具提示触发延迟发布
- 29. 工具提示位置设置
- 30. Winform工具提示位置设置