Delphi:禁用操作列表中的 1 个操作

发布于 2024-11-25 05:49:09 字数 306 浏览 4 评论 0原文

这很有趣:)但是如何做类似 ActionList1.MyAction.Enable:=false 的事情呢?

操作列表具有按钮的操作,如果按钮不可见,我需要禁用它的操作(如果不这样做并按下快捷方式,则将执行一个过程)。

可能是我做错了什么,但我没有将操作分配给按钮。我只有一个包含操作的操作列表。每个动作都有一个快捷方式。当按下此快捷键时,将执行该操作并执行一个过程。如果点击按钮->也将执行相同的程序。

State:=asSuspished 用于整个操作列表。

谢谢!!!

It is funny :) but how to do something like ActionList1.MyAction.Enable:=false?

An Action List has actions for buttons, if a button is invisible I need to disable it's action (if not to do this and pres a shortcut then a procedure will be performed).

May be I do something wrong, but I did not assign actions to buttons. I have only an Action List with Actions. Each action has a shortcut. When this shortcut is pressed then the action is executed and it performs a procedure. If to click on the button -> the same procedure will be performed too.

State:=asSuspended is for a whole Action List.

Thanks!!!

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

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

发布评论

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

评论(2

厌味 2024-12-02 05:49:09

您应该分配按钮的 Action 属性并通过操作控制一切。将操作设置为禁用、不可见等,按钮也会随之执行。

不要设置按钮的 OnClick 事件处理程序,而是使用操作的相应事件。使用操作的 OnUpdate 事件来设置 Visible、Enabled 等属性,基本上是运行时更改的所有内容。

You should assign the button's Action property and control everything via the action. Set the action to be disabled, invisible etc. and the button follows suit.

Don't set the OnClick event handler of the button, instead use the corresponding event of the action. Use the action's OnUpdate event to set properties like Visible, Enabled etc., basically everything that changes at runtime.

感性不性感 2024-12-02 05:49:09

TActionList 是一个包含一个或多个TAction 的列表。

TAction 具有以下属性:
自动检查
标题
已检查
已启用
组索引
帮助上下文
帮助关键字
帮助类型
提示
图片索引
次要捷径
快捷方式
Visible

只要您遵循 David 的建议并使用 TActionList 完成所有操作,

Enabled 就应该可以正常工作。或者,如果 taction.enabled 不适合您,您可以随时测试设置 actionxxxx.shortcut := ''; 是否有效。
如果没有,则其他快捷方式正在拦截击键。

请参阅:
http://docwiki.embarcadero.com/VCL/XE/en/ActnList.TAction
http://docwiki.embarcadero.com/VCL/en/ActnList.TActionList

TActionList is a list containing one or more TAction's.

TAction has the following properties:
AutoCheck
Caption
Checked
Enabled
GroupIndex
HelpContext
HelpKeyword
HelpType
Hint
ImageIndex
SecondaryShortCuts
ShortCut
Visible

Enabled should work just fine as long as your follow David's advice and do everything using the TActionList.

Alternatively if taction.enabled doesn't work for you, you can always test to see if setting actionxxxx.shortcut := ''; does the trick.
If not then some other shortcut is intercepting the keystroke.

See:
http://docwiki.embarcadero.com/VCL/XE/en/ActnList.TAction
http://docwiki.embarcadero.com/VCL/en/ActnList.TActionList

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