在JavaFX中显示禁用控件上的工具提示 [英] Show Tooltip on disabled Control in JavaFX

查看:236
本文介绍了在JavaFX中显示禁用控件上的工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在禁用的控件上显示工具提示吗?

It is possible to show a Tooltip on a disabled Control?

我有以下代码,但这不起作用:

I have the following code and this doesn't work:

txt_searchText.setDisable(true);
txt.searchText.setTooltip(new Tooltip("Message"));

有没有人能解决这个问题?

Has anyone a solution for that problem?

Thx

推荐答案

答案是否定的。目前您无法在禁用的节点上显示工具提示,原因很简单,禁用的节点不会收到任何MouseEvents。

The answer is no. Currently you cannot show a tooltip on disabled Node, for the simple reason that disabled Nodes do not receive any MouseEvents.

您可以在官方问题跟踪器中看到问题这里(要求登录): https://javafx-jira.kenai.com/browse/RT-28850

You can see the issue being raised in the official issue tracler here (require login) : https://javafx-jira.kenai.com/browse/RT-28850

您的问题的一个解决方案可能是将您的Control包装成其他内容。

One solution to your problem could be to wrap your Control into something else.

例如,put您可以控制另一个Control,例如SplitPane或Label。然后,您可以将工具提示应用于该包装并禁用您的第一个控件。

For example, put your control into another Control, like a SplitPane or a Label. Then you could apply your tooltip to that wrapper and disable your first control.

这篇关于在JavaFX中显示禁用控件上的工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆