delphidelphi-2009taction

TAction radio item


In action bands there is a TAction component.

That component holds a property named

GroupIndex: Integer;

however the field

RadioItem: Boolean;

is not there.

  1. Why is that?
  2. How can I make a TAction to be a checkbox?

The orientation of the action is ActionMainMenuBar and ActionManager.


Solution

  • Though TAction descends from TComponent, an action is not a component in the sense of a GUI element. It is meant to be linked to a GUI element, which for instance can be a radio button, a checkbox, or in your case a TActionClientItem on a TActionMainMenuBar.

    As for your questions:

    1. The GroupIndex property of an action indicates whether the action behaves like a radio item. The help says:

      GroupIndex is used to define groups of actions that act like radio buttons. When GroupIndex is greater than 0, it identifies the group to which the action belongs. When the Checked property of any action in that group is set to true, the Checked property of all other actions in the group is set to false. That is, only one action in the group can be checked at a time. Note: All actions in a group must be listed by the same action list or action manager.

    2. To show a menu item (a TActionClientItem) in an ActionMainMenuBar with a checkbox:

      • Create an action,
      • Set Checked to True,
      • Set the Category property,
      • Drag the category to the ActionMainMenuBar,
      • Ét voila.
      • Toggle the Checked property in the action's OnExecute event handler.

      To show a normal checkbox which is linked to an action in the ActionManager: do not use an ActionMainMenuBar, but an ActionToolBar on which you can drop the default checkbox component.