问题描述
用户可以通过多种方式触发动作(TAction):快捷键,工具栏按钮,弹出式菜单按钮等。是否可以获取该动作已被触发的信息?
There are a lot of ways how user can trigger an action (TAction) execution: shortcut keys, toolbar button, popup menu button etc. Is it possible to get information how that action has been triggered?
我正在考虑实施活动日志,以了解在GUI中使用不同功能的最流行方式。
I'm just thinking about implementation of activity log to figure out the most popular ways to use different features in GUI.
更新
我需要收集有关用户如何与应用程序GUI交互的统计信息。
I need to collect some stats about how an user interact with application GUI.
由于您需要实现日志记录,所以不要为每个按钮创建一个单独的动作。乌尔里希·格哈特的回答看起来很合适。我可以将一个处理程序分配给TActionList.OnExecute事件,并从一个地方写入日志。
It's not the best idea to create a separate action for every button just because you need to implement logging. Ulrich Gerhardt's answer looks suitable. I can assign a handler to TActionList.OnExecute event and write log from one place.
推荐答案
也许你可以使用:
当用户单击客户端控件时,
客户端在调用操作的执行
方法之前设置ActionComponent
。执行操作后,
操作将ActionComponent重置为nil
(Delphi)或NULL(C ++)。
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++).
还有,和可能更多的钩子。
There is also TApplication.OnActionExecute, TActionList.OnExecute and probably more "hooks".
这篇关于TAction已被解雇了哪种方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!