Delphi: 工具按钮 &动作-搞笑

发布于 2024-11-28 17:10:31 字数 76 浏览 4 评论 0原文

我有一个工具按钮和一个分配给它的操作。但该操作没有点击事件,也没有点击代码。因此该按钮被禁用,如何将其更改为启用?

谢谢!

I have a tool button and an assigned to it action. But the action doesn't have an on click event, there is no code for a click. Therefor the button is disabled, how to change it to be enabled?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画离情绘悲伤 2024-12-05 17:10:31

当某个操作没有 OnExecute 处理程序时,该操作始终处于禁用状态。如果您想将操作分配给对象并启用该对象,则需要提供一个 OnExecute 处理程序。

不过这个问题听起来有点奇怪。为什么你会有一个按下时没有任何反应的按钮?您是否可能有一个在按钮而不是操作中定义的 OnClick 处理程序?如果是这样,那么您只需将该处理程序移至操作中,一切都会好起来的。

更新

Ulrich 很有帮助地指出 DisableIfNoHandler< TAction 的 /code>可用于更改上述行为。由于它具有公众可见性并且未发布,因此您必须更改代码,这就是为什么我认为我忘记了它。

When an action has no OnExecute handler, the action is always disabled. If you want to assign an action to an object, and have that object be enabled, then you need to provide an OnExecute handler.

The question sounds a little odd though. Why would you have a button which, when pressed, does nothing? Do you perhaps, have an OnClick handler that is defined in the button rather than the action? If so then you should simply move that handler into the action and all will be well.

Update

Ulrich helpfully points out that the DisableIfNoHandler of TAction can be used to change the behaviour described above. Since this has public visibility and is not published, you have to make the change in code which is why I think I forgot about it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文