Delphi: 工具按钮 &动作-搞笑
我有一个工具按钮和一个分配给它的操作。但该操作没有点击事件,也没有点击代码。因此该按钮被禁用,如何将其更改为启用?
谢谢!
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当某个操作没有
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 anOnExecute
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
ofTAction
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.