Add new property to Action in TActionList

delphi, taction, tactionlist

Solution

Create your new action class by deriving from `TAction`. For example:

TMyAction = class(TAction)
...
published
  property MyBoolProp: Boolean ....
end;

And then you can register it from your design time package's `Register` procedure by calling `RegisterActions`.

procedure Register;
begin
  .... // register any other components
  RegisterActions('MyCategory', [TMyAction], nil);
end;

Then from the action list editor, select `New Standard Action` and your action will appear in the tree view of available actions.

In the comments you seem to imply that you want to modify `TAction` to have a new property. That would require modification to the VCL itself and that's beyond your control. No doubt the VCL could be hacked to achieve what you ask for but that's not a good idea.

Problem

How can I add new published (to be shown in Object Inspector) property to the Action of TActionList in Delphi the property data type is Boolean. Thanks.

Original source