Skip to main content

Interfaces

Interface names are listed here as a reference inventory for this.interfaces usage. Most act as capability markers.

Interface Index

InterfaceDescription
IClassFactoryRegisters classes dynamically via this.classes array
ICommandHandlerHandles command interpretation callbacks
IComponentBase component / shared object interface
IControllerController for dialog and view parameter bindings
IEditTaskEditable action lifecycle
IExtensionHandlerExtension lifecycle handler
IObjectNodeObject-tree node interface for UI models
IObserverReceives callbacks from Host.Signals
IParamObserverParameter-change observer for bound dialog/control parameters
IPersistAttributesSaves and restores attributes/state
IViewStateHandlerSaves and restores view state for add-ins

Callback Contracts

Each interface defines a set of required callbacks or properties that must be present on an implementing object.

InterfaceRequired callback(s)
IClassFactorythis.classes, this.version, createInstance(classID)
ICommandHandlercheckCommandCategory(category), interpretCommand(msg)
IComponentinitialize(context?), terminate()
IControllerparamChanged(param)
IEditTaskprepareEdit() and performEdit()
IExtensionHandlerinitialize(context), startupExtension(description), terminate()
IObjectNodechildren array property
IObservernotify(subject, msg)
IParamObserverparamChanged(param)
IPersistAttributesstoreValues(attributes), restoreValues(attributes)
IViewStateHandlerinitialize(context), saveViewState(viewID, viewName, attributes), loadViewState(viewID, viewName, attributes), terminate()

IClassFactory

Registers classes dynamically at runtime via this.classes and this.version. Uses CodeResource:Executable in metainfo.xml instead of classfactory.xml. Requires defining CCLGetClassFactory(codeResource) as a global function — the host calls it on package load and expects an object implementing IClassFactory.

The host calls createInstance(classID) for FrameworkService class registrations. Other categories (EditTask, Toolset, etc.) are registered but not auto-instantiated — instances can be created manually via factory.createInstance().

Properties:

PropertyTypeWritableExampleDescription
classesArrayYes[{ name: "MyTask", category: "EditTask", classID: Host.UID("{...}") }]Array of class descriptors with name, category, classID
versionobjectYes{ name: "My Package", version: "1.0.0", vendor: "MyVendor" }Version descriptor with name, version, vendor strings

Methods:

MethodReturnsParametersDescription
createInstance(classID)objectclassIDHost.UID to match against registered classesCreates an instance for the matching class
var gFactory = null;

function CCLGetClassFactory(codeResource)
{
gFactory = {
interfaces: [Host.Interfaces.IClassFactory],
classes: [
{ name: "MyService", category: "FrameworkService", classID: Host.UID("{...}") },
{ name: "MyTask", category: "EditTask", classID: Host.UID("{...}") }
],
version: {
name: "My Package",
version: "1.0.0",
vendor: "MyVendor"
},
createInstance: function(classID) {
if (classID.equals(Host.UID("{...}")))
return { interfaces: [Host.Interfaces.IComponent], initialize: function(c) { return Host.Results.kResultOk }, terminate: function() {} };
return null;
}
};
return gFactory;
}

In metainfo.xml:

<Attribute id="CodeResource:Executable" value="main.js"/>

ICommandHandler

Receives command dispatch from CCL menus, context menus, and the host command system.

Methods:

MethodReturnsParametersDescription
checkCommandCategory(category)booleancategory — command category stringCalled to query whether this handler can process the given category. Return true to accept commands of this category
interpretCommand(msg)booleanmsg — command messageCalled when a command is dispatched — first with msg.checkOnly = 1 to probe for availability, then with msg.checkOnly = 0 for execution. Return true if handled, false to pass through

Command msg object properties:

PropertyTypeWritableExampleDescription
categorystringNo"View"Command category
namestringNo"Browser"Command name
checkOnlyflagNo11 if this is a query call to check availability, 0 for actual execution
this.interfaces = [Host.Interfaces.ICommandHandler];

this.checkCommandCategory = function(category) {
return category == "MyCategory";
};

this.interpretCommand = function(msg) {
if (msg.checkOnly) return true; // probe — always claim if willing to handle
// msg.category, msg.name, msg.checkOnly (0 → execute)
return true; // true = handled, false = not handled
};

IComponent

Base lifecycle interface for components. initialize(context) is called when the component starts; terminate() is called on shutdown.

Methods:

MethodReturnsParametersDescription
initialize(context)context — host context for registration and lookupCalled when the component starts
terminate()noneCalled on component shutdown for cleanup
this.interfaces = [Host.Interfaces.IComponent];

this.initialize = function(context) {
return Host.Results.kResultOk;
};

this.terminate = function() {
return Host.Results.kResultOk;
};

IController

Identity marker for dialog and view parameter bindings. paramChanged(param) fires when a bound control changes.

Methods:

MethodReturnsParametersDescription
paramChanged(param)paramparam object.Called when a bound parameter changes

param supports identity comparison (param === this.myParam)

this.interfaces = [Host.Interfaces.IController, Host.Interfaces.IParamObserver];

this.initialize = function(panel) {
this.paramList = Host.Classes.createInstance("CCL:ParamList");
this.paramList.controller = this;
};

this.paramChanged = function(param) {
// Called when a bound parameter changes.
};

IEditTask

Editable action lifecycle. prepareEdit(context) sets up parameters and optionally shows a dialog; performEdit(context) executes the action.

Methods:

MethodReturnsParametersDescription
prepareEdit(context)context — edit context (see context object).Called first. Set up parameters and return runDialog() or kResultOk
performEdit(context)context — edit context (see context object)Called after dialog closes to execute the action
this.interfaces = [Host.Interfaces.IEditTask];

this.prepareEdit = function(context) {
return Host.Results.kResultOk;
};

this.performEdit = function(context) {
return Host.Results.kResultOk;
};

IExtensionHandler

Receives notifications about installed extensions at startup. Uses category="ExtensionHandler" in classfactory.xml. startupExtension(description) fires once per detected extension during host startup.

Typically paired with IComponent.

Methods:

MethodReturnsParametersDescription
initialize(context)context — host context for registration and lookupCalled when the extension handler starts
startupExtension(description)description — Extension descriptorCalled once per installed extension at startup
terminate()noneCalled on handler shutdown for cleanup

Extension descriptor

The description object passed to startupExtension identifies an available extension package. The platformIndependentId matches the extension's Package:ID in its metainfo.xml.

Properties:

PropertyTypeWritableExampleDescription
pathobjectNodescription.pathHost.Url-like object with .saveToFile()/.loadFromFile()
platformIndependentIdstringNo"com.test.extension"Matches the extension's Package:ID
idstringNo"com.test.extension"Platform-specific identifier (often same as platformIndependentId)
this.interfaces = [Host.Interfaces.IExtensionHandler, Host.Interfaces.IComponent];

this.initialize = function(context) {
Host.Objects.registerObject(this, "MacroExtensionHandler");
return Host.Results.kResultOk;
};

this.startupExtension = function(description) {
return 1;
};

this.terminate = function() {
Host.Objects.unregisterObject(this);
return Host.Results.kResultOk;
};

IObjectNode

Represents a node in an object tree.

Properties:

PropertyTypeWritableExampleDescription
childrenArrayYesthis.children = []Array of child objects.
this.interfaces = [Host.Interfaces.IObjectNode];

this.children = [];

this.initialize = function(context) {
this.children.push(someChildObject);
};

this.terminate = function() {
this.children.length = 0;
};

IObserver

notify(subject, msg) receives signals from advised objects. The msg object carries the signal data.

Method:

MethodReturnsParametersDescription
notify(subject, msg)subject — the signal source object, msg — signal payloadCalled when an advised signal fires on the channel

msg object

Properties:

PropertyTypeWritableExampleDescription
idstringYes"commandFocused"Signal identifier
argCountnumberNo1Number of arguments

Methods:

MethodReturnsParametersDescription
getArg(index)objectindex — 0-based argument indexReturns the argument at the given index. Surface depends on the signal id
this.interfaces = [Host.Interfaces.IObserver];

Host.Signals.advise("my-channel-name", this);

this.notify = function(subject, msg) {
if (msg.id === "someSignal") {
var arg = msg.getArg(0);
}
};

IParamObserver

Parameter-change observer for bound dialog/control parameters.

Methods:

MethodReturnsParametersDescription
paramChanged(param)paramparamCalled when a bound parameter changes
this.interfaces = [Host.Interfaces.IParamObserver];

this.paramChanged = function(param) {
// Called when a dialog/control parameter changes.
};

IPersistAttributes

Saves and restores attribute state across invocations. storeValues(attributes) fires before the dialog closes; restoreValues(attributes) fires when the dialog reopens. Persistence scope matches context.parameters (across invocations within a session, not across app restarts).

Methods:

MethodReturnsParametersDescription
storeValues(attributes)attributes - attributes objectCalled to persist attribute state
restoreValues(attributes)attributesattributes objectCalled to restore attribute state

attributes object

The attributes parameter is passed to storeValues/restoreValues (IPersistAttributes) and saveViewState/loadViewState (IViewStateHandler). It has the same surface as Host.Attributes.

this.interfaces = [Host.Interfaces.IPersistAttributes];

this.storeValues = function(attributes) {
attributes.setAttribute("myValue", this.myParam.value);
return Host.Results.kResultOk;
};

this.restoreValues = function(attributes) {
var val = attributes.getAttribute("myValue");
if (val !== undefined) this.myParam.value = val;
return Host.Results.kResultOk;
};

IViewStateHandler

Persists and restores panel/view state across song sessions. Works with EditAddIn panels.

Methods:

MethodReturnsParametersDescription
initialize(context)context — add-in contextCalled on add-in startup
terminate()noneCalled on add-in shutdown for cleanup
saveViewState(viewID, viewName, attributes)viewID — the script classID GUID from classfactory.xml, viewName - the groupName from classfactory.xml, attributesattributes objectCalled to persist panel state
loadViewState(viewID, viewName, attributes)viewID — the script classID GUID from classfactory.xml, viewName — the groupName from classfactory.xml, attributesattributes objectCalled to restore panel state
this.interfaces = [Host.Interfaces.IViewStateHandler];

this.initialize = function(context) {
return Host.Results.kResultOk;
};

this.saveViewState = function(viewID, viewName, attributes) {
attributes.setAttribute("selectedPage", this.pageSelector.value);
return true;
};

this.loadViewState = function(viewID, viewName, attributes) {
var val = attributes.getAttribute("selectedPage");
if (val !== undefined) this.pageSelector.value = val;
return true;
};

this.terminate = function() {
return Host.Results.kResultOk;
};