Adding an Action to the Action List
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:
- Create your instance of
TAction
with the action list object as parent. The action list object is theActionList
property of theBorlandIDEServices
variable casted asINTAServices
. - Configure your action. For example:
- Define some of its properties, such as Name, Caption, Hint, or ShortCut.
- Assign an event handler to its OnExecute event. The IDE executes the specified event handler when a user executes your action.
- Assign an event handler to its OnUpdate event, for example to handle when your action is enabled or disabled.
- To define an icon for your action, add your icon to the image list of the IDE and assign its index to the ImageIndex property of your action.
- Configure your action so that users can add it to a toolbar.
- Call
AddActionMenu
on theBorlandIDEServices
variable casted asINTAServices
, and provide the following parameters:- An empty string. The first parameter is only required when you add a menu item to the main menu.
- Your action object.
- 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.