ScriptManager

This module provides many functions to integrate scripted functionalities in the UI of Harmony.

Methods

(static) addAction(action)

This method defines an action that can be called by a menu, a shortcut or a toolbar button. Please note that callback functions must be quick if defined because they might have a performance impact on the whole application.
Example

Here is an example of a preference toggler action. After the action has been added to the list of actions, it can be used in menus and toolbars or via the action manager.

 // Defining the action
 var toggleCoordinatesAction = {
  id: "com.toonboom.toggleMouseCoordinateDisplay",
  text: "Toggle Mouse Coordinates Display Settings",
  icon: "earth.png",
  checkable: true,
  isEnabled: true,
  isChecked: preferences.getBool("DRAWING_VIEW_SHOW_RAW_MOUSE_COORDINATES", false),
  onPreferenceChanged: function () {
    this.isChecked = preferences.getBool("DRAWING_VIEW_SHOW_RAW_MOUSE_COORDINATES", false);
  },
  onTrigger: function () {
    this.isChecked = !this.isChecked;
    preferences.setBool("DRAWING_VIEW_SHOW_RAW_MOUSE_COORDINATES", this.isChecked);
  }
};
// Adding the action to the system
ScriptManager.addAction(toggleCoordinatesAction);

// Adding the action in a menu of Harmony
ScriptManager.addMenuItem({
    targetMenuId: "View",
    id: toggleCoordinatesAction.id,
    text: toggleCoordinatesAction.text,
    action: toggleCoordinatesAction.id
 });

 // Here is how to call the action from the Action object
 Action.perform("onTriggerScriptAction(QString)", "ScriptManagerResponder", toggleCoordinatesAction.id);
Parameters:
Name Type Description
action Object The definition of the action.
Properties
Name Type Description
id String The action uniqueId. Is is recommended to use reverse DNS notation.
text String The action label.
icon String The icon for the action
checkable boolean If true, the action is checkable
isEnabled boolean | function If true, the action is enabled. If a function is provided, the action must return true or false.
isChecked boolean | function If true, the action is checked. If a function is provided, the action must return true or false.
onTrigger function The function to call if the action is triggered in any way (ActionManager, menu item, toolbar).
onSelectionChanged function Callback function called when the selection changes.
onCurrentFrameChanged function Callback called when the current frame of the scene changes.
onNetworkChanged function Callback called when connections have been changed in the network view or if new modules have been created.
onPreferenceChanged function Callback called when a preference has changed.

(static) addShortcut()

This method adds a shortcut to the list of Harmony shortcuts.

(static) addToolbar(toolbar)

This method adds a toolbar to Harmony.
Parameters:
Name Type Description
toolbar ScriptToolbarDef The toolbar to add