How was TAction fired?

There are many ways a user can trigger an action (TAction): keyboard shortcuts, toolbar button, popup menu button, etc. Can I get information about how this action was initiated?

I'm just thinking of implementing an activity log to figure out the most popular ways to use different functions in the GUI.

Update

I need to collect some statistics on how the user interacts with the application GUI.

It is not a good idea to create a separate action for each button just because you need to implement logging. Ulrich Gerhardt's answer seems appropriate. I can assign a TActionList.OnExecute event handler and write a log from one place.

+6
delphi
source share
1 answer

Perhaps you can use ActionComponent :

Use an ActionComponent to determine which client component invoked this action. to fulfill. For example, learn the ActionComponent from OnExecute if you need to know that a user action triggered this action.

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

There is also TApplication.OnActionExecute , TActionList.OnExecute and probably more "interceptors".

+11
source share

All Articles