delphitactiontactionlist

Add new property to Action in TActionList


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.


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.

    enter image description here

    enter image description here


    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.