Adding an Action to the Action List

From RAD Studio
Jump to: navigation, search

Go Up to Using Native IDE Objects


You can use the INTAServices Native Tools API interface to extend the action list of the IDE with your own actions.

Adding an Action to the Action List

To add an instance of TAction to the action list of the IDE:

  1. Create your instance of TAction with the action list object as parent. The action list object is the ActionList property of the BorlandIDEServices variable casted as INTAServices.
  2. Configure your action. For example:
  3. Call AddActionMenu on the BorlandIDEServices variable casted as INTAServices, and provide the following parameters:
    1. An empty string. The first parameter is only required when you add a menu item to the main menu.
    2. Your action object.
    3. Nil. This parameter is only required to add a menu item to the main menu as well.

Delphi:

if Supports(BorlandIDEServices, INTAServices, NTAServices) then
begin
  MyAction := TAction.Create(nil);
  MyAction.Caption := 'My Action';
  NTAServices.AddActionMenu('', MyAction, nil);
end;

C++:

_di_INTAServices NTAServices;
if (BorlandIDEServices->Supports(NTAServices)) {
  MyAction = new TAction(NULL);
  MyAction->Caption = "My Action";
  NTAServices->AddActionMenu("", MyAction, NULL);
}

Allowing Users to Add Your Action to a Toolbar

To allow users to add your action to a toolbar of the IDE, fill the Category property of your action with some value. For example, "My Actions". Then users can add your action to any toolbar as a button.

If you allow users to add your action to a toolbar, in your finalization code you must find all tool buttons that refer to your action, and remove those buttons.

See Also