Writing Action Components

From RAD Studio
Jump to: navigation, search

Go Up to Handling VCL Actions Using an Action List

You can also create your own predefined action classes. When you write your own action classes, you can build in the ability to execute on certain target classes of objects. Then, you can use your custom actions in the same way you use predefined action classes. That is, when the action can recognize and apply itself to a target class, you can simply assign the action to a client control, and it acts on the target with no need to write an event handler.

Component writers can use the classes in the StdActns and DBActns units as examples for deriving their own action classes to implement behaviors specific to certain controls or components. The base classes for these specialized actions (TEditAction, TWindowAction, and so on) generally override HandlesTarget, UpdateTarget, and other methods to limit the target for the action to a specific class of objects. The descendent classes typically override ExecuteTarget to perform a specialized task. These methods are described here:

Methods overriden by base classes of specific actions

Method Description


Called automatically when the user invokes an object (such as a tool button or menu item) that is linked to the action. The HandlesTarget method lets the action object indicate whether it is appropriate to execute at this time with the object specified by the Target parameter as a "target". See How Actions Find Their Targets for details.


Called automatically when the application is idle so that actions can update themselves according to current conditions. Use in place of OnUpdateAction. See Updating Actions for details.


Called automatically when the action fires in response to a user action in place of OnExecute (for example, when the user selects a menu item or presses a tool button that is linked to this action). See What Happens When an Action Fires for details.

When you write your own action classes, it is important to understand the following:

See Also