Skip to main content

Implementing Handlers using Scripts

Overview

For commands and events defined as extension points in the manifest, the processing for those commands is implemented.

The functions that implement this processing are called command handlersandevent handlers.

These handlers are implemented in the script file specified as the entry point in the manifest.

Implementation Example

An example of implementing a command handler is shown for the case where the following command is defined in the manifest.

Example of a command definition in a manifest

manifest.json
"extensionPoints": {
"commands": [
{
"id": "Command.SayHello",
"execFunc": "SayHello"
}
],

...
}

In the above command definition example, the command handler named SayHello, specified in the extensionPoints.commands[0].execFunc property, is implemented as a public function in the entry point's script file.

Example of implementing a command handler in a script file

main.cs
//Command handler
public void SayHello(ICommandContext context, ICommandParams commandParams)
{
App.Window.UI.ShowInformationDialog("Hello !", "Hello World");
}
  • For details on global objects available in scripts, see Global Objects.

For details on arguments passed to command handlers, see the following reference.

important
  • In C#, handlers must be implemented as public functions.
  • In Python, handlers are defined as top-level functions.
  • All handlers must be implemented in the script file specified as the entry point.