Show: Delphi C++
Display Preferences

RTL Actions

From RAD Studio
Jump to: navigation, search

Go Up to RTL


GUI applications often provide different menus, tool bar buttons and other controls that execute the same code and share some other properties, such as their display text, their hint, their shortcut, their context help, and more. Actions let you define the code that they execute and most of their common properties in a single place, which makes your code easier to maintain.

An action is an object that encapsulates a response to user interaction. An action represents a command object in the command pattern of object-oriented programming. The RTL provides action features that are independent of the GUI application frameworks.

An action defines code that runs when you execute the action, and properties that represent aspects of the action, such as whether it can be executed or not, which shortcut triggers the action, or which image represents the action.

You can associate actions with GUI controls such as menu commands or toolbar buttons. A GUI control that is associated with an action is known as a "client" of that action. When a user clicks or otherwise triggers the client of an action, the client executes the action. Actions also affect their clients; for example, if an action is disabled, their clients are disabled as well.

You may also associate some actions with a "target" component that received the effect of the action when the action is executed.

The main RTL class to represent an action is TContainedAction. For really simple actions that only provide code to execute, or to create custom action classes, you can alternatively use TBasicAction.

Defining the Code that an Action Executes

To define the code that an action execute, simply provide an event handler for its OnExecute event.

Registering Standard Actions

Use RegisterActions in an IDE extension to register custom action classes as standard actions. Standard actions are actions that you can easily add to your applications using the IDE.

See Also

Personal tools
RAD Studio 10.2 Tokyo
In other languages
Previous Versions
Assistance