RAD Studio
ContentsIndex
PreviousUpNext
What Is an Action?

As you are developing your application, you can create a set of actions that you can use on various UI elements. You can organize them into categories that can be dropped onto a menu as a set (for example, Cut, Copy, and Paste) or one at a time ( for example, ToolsCustomize ). 

An action corresponds to one or more elements of the user interface, such as menu commands or toolbar buttons. Actions serve two functions: (1) they represent properties common to the user interface elements, such as whether a control is enabled or checked, and (2) they respond when a control fires, for example, when the application user clicks a button or chooses a menu item. You can create a repertoire of actions that are available to your application through menus, through buttons, through toolbars, context menus, and so on. 

Actions are associated with other components:

  • Clients: One or more clients use the action. The client most often represents a menu item or a button (for example, TToolButton, TSpeedButton, TMenuItem, TButton, TCheckBox, TRadioButton, and so on). Actions also reside on ActionBand components such as TActionMainMenuBar and TActionToolBar. When the client receives a user command (such as a mouse click), it initiates an associated action. Typically, a client's OnClick event is associated with its action's OnExecute event.
  • Target: The action acts on the target. The target is usually a control, such as a memo or a data control. Component writers can create actions specific to the needs of the controls they design and use, and then package those units to create more modular applications. Not all actions use a target. For example, the standard help actions ignore the target and simply launch the help system.
A target can also be a component. For example, data controls change the target to an associated dataset. 

The client influences the action—the action responds when a client fires the action. The action also influences the client—action properties dynamically update the client properties. For example, if at runtime an action is disabled (by setting its Enabled property to False), every client of that action is disabled, appearing grayed. 

You can add, delete, and rearrange actions using the Action Manager or the Action List editor (displayed by double-clicking an action list object, TActionList). These actions are later connected to client controls. See Creating toolbars and menus and, for cross-platform development, Setting up action lists for details.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!