是否可以更改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. Flex 3:errorstring工具提示延遲?
- 4. 有延遲的gwt工具提示
- 5. PySide:即時工具提示(在顯示工具提示前不延遲)
- 6. 設置延遲
- 7. Highcharts:顯示前的工具提示延遲
- 8. 如何實現延遲顯示twipsy工具提示
- 9. 的jquery - 延遲加載 - 設置延遲
- 10. 有沒有辦法在eclipse工具提示中添加延遲?
- 11. Twitter引導工具提示插件中的數據延遲
- 12. Highstock v3.0如何禁用工具提示超時/延遲
- 13. visual studio 2010智能感知工具提示延遲
- 14. jQuery UI工具提示延遲沒有效果
- 15. Chart.js(折線圖)工具提示持續時間/延遲
- 16. Datagridview單元格工具提示延遲時間
- 17. MS圖表:可能會減少工具提示延遲?
- 18. 工具提示位置設置
- 19. Winform工具提示位置設置
- 20. 是否可以爲IBeacon提示設置延遲時間?
- 21. 在SWT Combo小部件中設置每個元素的工具提示文本
- 22. 設置工具提示編輯
- 23. 設置工具提示等於內容
- 24. 設置TextBlock的工具提示內容
- 25. 如何推遲ngx-bootstrap工具提示?
- 26. 工具提示當光標移到文本框上時顯示2秒延遲
- 27. java jtree重新顯示延遲後的每個項目的工具提示
- 28. EditText.getText具有延遲
- 29. 測量TCP連接延遲的工具
- 30. WPF工具提示項目不會重新觸發初始延遲