gpt4 book ai didi

delphi - TAction 是通过什么方式被触发的?

转载 作者:行者123 更新时间:2023-12-03 14:58:04 26 4
gpt4 key购买 nike

用户可以通过多种方式触发操作(TAction)执行:快捷键、工具栏按钮、弹出菜单按钮等。是否可以获取该操作如何被触发的信息?

我只是在考虑事件日志的实现,以找出在 GUI 中使用不同功能的最流行的方法。

更新

我需要收集一些有关用户如何与应用程序 GUI 交互的统计信息。

仅仅因为需要实现日志记录就为每个按钮创建单独的操作并不是最好的主意。乌尔里希·格哈特的答案看起来很合适。我可以为 TActionList.OnExecute 事件分配一个处理程序,并从一个地方写入日志。

最佳答案

也许你可以使用ActionComponent :

Use ActionComponent to discern which client component caused this action to execute. For example, examine ActionComponent from an OnExecute event handler if you need to know what user action triggered this action.

When the user clicks a client control, that client sets ActionComponent before calling the action's Execute method. After the action executes, the action resets ActionComponent to nil (Delphi) or NULL (C++).

还有TApplication.OnActionExecute , TActionList.OnExecute可能还有更多“钩子(Hook)”。

关于delphi - TAction 是通过什么方式被触发的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5501123/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com