Using Actions in a FireMonkey Application

From Appmethod Topics
Jump to: navigation, search

Go Up to FireMonkey Actions

FMX action lists

You can create a list of actions that are available to your application through menus, controls, toolbars, context menus, and so on. You can add, delete, and rearrange actions in FMX action lists using the Action List editor. Then actions can be associated to UI elements like menu commands and controls.

Managing FMX actions using FMX action lists is fairly easy once you understand the basic steps involved:

  • Create the action list.
  • Add actions to the action list.
  • Set properties on the actions.
  • Attach clients to the action.

Here are the steps in more detail

  1. Open a FireMonkey project.
  2. Open your FMX form in the Form Designer.
  3. From the Tool Palette, drop a TFMXActionList onto your form.
  4. Double-click the TFMXActionList object to display the Action List editor. The Action List editor shows the current list of actions. You can add new actions to this list:
    • To add predefined standard actions known in the project, right-click the Categories or Actions (FMX) pane and choose New Standard Action on the context menu. The Standard Action Classes dialog box opens. It shows the lists of predefined standard actions known in the project. The predefined actions are organized into categories (such as File, View, Edit, Help, and Window). Select the standard actions you want to add to the action list, and click OK.
    • To create a new action of your own, right-click the Categories or Actions (FMX) pane and choose New Action on the context menu. The new action appears in the Actions (FMX) pane.
  5. Select actions one by one, and set their properties in the Object Inspector.
    • The properties you set affect every client of the action.
    • The Name property identifies the action.
    • Other properties and events (Caption, Checked, Enabled, HelpContext, Hint, ImageIndex, ShortCut, Visible, and Execute) correspond to the properties and events of the client.
    • The client's corresponding properties typically, but not necessarily, have the same name as the corresponding action property.
    • If you use the predefined actions, the action includes a standard response that occurs automatically.
    • If you create your own action, you need to write an event handler that defines how the action responds when fired. See What Happens When an Action Fires for details.
  6. Attach the actions to the clients that require them:
    • In the Form Designer, select the control (such as the button or menu item). In the Object Inspector, the Action property lists the actions available in the created action lists.
    • Select the action you want. The control becomes the client of this action.

See Also

Application Samples