Which way that TAction has been fired?
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?
I'm just thinking about implementation of activity log to figure out the most popular ways to use different features in GUI.
update
I need to collect some stats about how an user interact with application GUI.
It's not the best idea to create a separate action for every button just because you need开发者_如何学Go to implement logging. Ulrich Gerhardt's answer looks suitable. I can assign a handler to TActionList.OnExecute event and write log from one place.
Maybe you can use 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++).
There is also TApplication.OnActionExecute, TActionList.OnExecute and probably more "hooks".
精彩评论