[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'ActnList' (#lcl)

# TCustomAction

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

TCustomAction is the ancestor class for TAction.

## Declaration

Source position: actnlist.pas line 150

`type TCustomAction = class(TContainedAction)`
`protected`
`FImage: TObject;`
`FMask: TObject;`
`procedure AssignTo(); override;` |  | Copies property from the class instance to the specified persistent object.
`function HandleShortCut; virtual;` |  | Returns True if the action is enabled and executed successfully.
`procedure SetAutoCheck(); virtual;` |  | Sets the value for the AutoCheck property.
`procedure SetCaption(); virtual;` |  | Sets the value for the Caption property.
`procedure SetChecked(); virtual;` |  | Sets the value for the Checked property.
`procedure SetEnabled(); virtual;` |  | Sets the value for the Enabled property.
`procedure SetGroupIndex(); virtual;` |  | Sets the value for the GroupIndex property.
`procedure SetHelpContext(); virtual;` |  | Sets the value for the HelpContext property.
`procedure SetHelpKeyword(); virtual;` |  | Sets the value for the HelpKeyword property.
`procedure SetHelpType(); virtual;` |  | Sets the value for the HelpType property.
`procedure SetHint(); virtual;` |  | Sets the value for the Hint property.
`procedure SetImageIndex(); virtual;` |  | Sets the value for the ImageIndex property.
`procedure SetName(); override;` |  | Sets the value for the Name property.
`procedure SetShortCut(); virtual;` |  | Sets the value for the ShortCut property.
`procedure SetVisible(); virtual;` |  | Sets the value for the Visible property.
`property SavedEnabledState: Boolean; [rw]` |  | SavedEnabledState - if True, the Enabled state has been saved.
`public`
`constructor Create(); override;` |  | Constructor for the class instance.
`destructor Destroy; override;` |  | Destroy - destructor for TCustomAction: frees various lists and images, then calls inherited Destroy.
`function DoHint(); virtual;` |  | DoHint - method for displaying the hint contained in HintStr if True value is returned.
`function Execute; override;` |  | Executes the action using an available OnExecute event handler.
`property AutoCheck: Boolean; [rw]` |  | AutoCheck - whether the control (e.g. a CheckBox) is to be automatically checked.
`property Caption: TTranslateString; [rw]` |  | The Caption to be used if this action is associated with a visible component.
`property Checked: Boolean; [rw]` |  | Whether the check box control associated with the action is Checked (default False).
`property Grayed: Boolean; [rw]` |  | True if the action (and it client control) are in the grayed or indeterminate state.
`property DisableIfNoHandler: Boolean; [rw]` |  | Prevents the action from executing if an OnExecute handler is not assigned in the action.
`property Enabled: Boolean; [rw]` |  | Enabled - whether this action is able to be used (default is True).
`property GroupIndex: Integer; [rw]` |  | GroupIndex- Index of the action within its group.
`property HelpContext: THelpContext; [rw]` |  | HelpContext - the index for a context-based help message.
`property HelpKeyword: string; [rw]` |  | HelpKeyWord - the keyword of a context-based help message.
`property HelpType: THelpType; [rw]` |  | HelpType - the sort of help message to be offered: default Context-based.
`property Hint: TTranslateString; [rw]` |  | Hint - a pop-up message that appears when the mouse hovers over an object.
`property ImageIndex: TImageIndex; [rw]` |  | ImageIndex - the index number of the image to be associated with this action.
`property OnHint: THintEvent; [rw]` |  | OnHint - action to be taken when a hint is required.
`property SecondaryShortCuts: TShortCutList; [rws]` |  | SecondaryShortCuts - a stringlist containing shortcuts.
`property ShortCut: TShortCut; [rw]` |  | ShortCut- an index to a shortcut list.
`property Visible: Boolean; [rw]` |  | Visible - is this action visible? (default True).
`end;`

## Inheritance

`TCustomAction` |  | TCustomAction is the ancestor class for TAction.
`TContainedAction` |  | Implements an Action class which has a category and parent action list.
`TBasicAction`
?
`TObject`

## Description

TCustomAction is a generic class for all components that represents actions that can be be set on the user interface for buttons and other controls. TCustomAction is the ancestor for TAction. If you want to define your own action class, you should derive it from this class.

You can assign a action to a component by using the Object Inspector.

## Version info

Modified in LCL version 4.0 to improve compatibility with newer Delphi VCL versions. Some methods were redefined as virtual and changed to protected visibility.

## See also

TAction |  | TAction is the basic action object used in the LCL.