Class helper for updating a TActionList

On occasions I've wanted to provoke all actions in an action list to update themselves - when waiting for the application to update them when idle isn't soon enough.

I would have thought that TActionList would have a suitable method, but it doesn't seem to.

To save having to come up with the same hack over and again, I've started using this class helper:

type
  TActionListHelper = class helper for TCustomActionList
  public
    procedure Update;
  end;
...
procedure TActionListHelper.Update;
var
  Action: TContainedAction;
begin
  for Action in Self do
    Action.Update;
end;

You can now update all the actions in an action list by calling the Update that has been injected into any TActionList instance.

Seems to work so I thought I'd share it.

If you've got a better way, please comment.

Comments

Popular posts from this blog

Deleting elements from a dynamic array

Initialising dynamic arrays

New String Property Editor Planned For RAD Studio 12 Yukon 🤞