Class: oApp

$. oApp

The $.oApp class provides access to the Harmony application and its widgets.

new $.oApp()

openHarmony/openHarmony_application.js, line 58
The constructor for the $.oApp class

Members

currentStencil$.oStencil

The currently selected stencil. Always returns the pencil tool current stencil.

currentTool$.oTool

The Position of the mouse cursor in the screen coordinates.

readonlyflavourstring

The software flavour: Premium, Advanced, Essential

readonlyglobalMousePosition$.oPoint

The Position of the mouse cursor in the screen coordinates.

readonlymainWindowQWidget

The Harmony Main Window.

readonlymousePosition$.oPoint

The Position of the mouse cursor in the toonboom window coordinates.

preferences

Access the Harmony Preferences
Example
// To access the preferences of Harmony, grab the preference object in the $.oApp class:
var prefs = $.app.preferences;

// It's then possible to access all available preferences of the software:
for (var i in prefs){
  log (i+" "+prefs[i]);
}

// accessing the preference value can be done directly by using the dot notation:
prefs.USE_OVERLAY_UNDERLAY_ART = true;
log (prefs.USE_OVERLAY_UNDERLAY_ART);

//the details objects of the preferences object allows access to more information about each preference
var details = prefs.details
log(details.USE_OVERLAY_UNDERLAY_ART.category+" "+details.USE_OVERLAY_UNDERLAY_ART.id+" "+details.USE_OVERLAY_UNDERLAY_ART.type);

for (var i in details){
  log(i+" "+JSON.stringify(details[i]))       // each object inside detail is a complete oPreference instance
}

// the preference object also holds a categories array with the list of all categories
log (prefs.categories)

stencilsArray.<$.oStencil>

The list of stencils available in the Harmony UI.
Example
// Access the stencils list through the $.app object.
var stencils = $.app.stencils

// list all the properties of stencils
for (var i in stencils){
  log(" ---- "+stencils[i].type+" "+stencils[i].name+" ---- ")
  for(var j in stencils[i]){
    log (j);
  }
}

readonlytoolbarsQToolbar

The Harmony UI Toolbars.

readonlytoolsArray.<$.oTool>

Access the tools available in the application
Example
// Access the list of currently existing tools by using the $.app object
var tools = $.app.tools;

// output the list of tools names and ids
for (var i in tools){
  log(i+" "+tools[i].name)
}

// To get a tool by name, use the $.app.getToolByName() function
var brushTool = $.app.getToolByName("Brush");
log (brushTool.name+" "+brushTool.id)            // Output: Brush 9

// it's also possible to activate a tool in several ways:
$.app.currentTool = 9;         // using the tool "id"
$.app.currentTool = brushTool  // by passing a oTool object
$.app.currentTool = "Brush"    // using the tool name

brushTool.activate()           // by using the activate function of the oTool class

readonlyversionint

The Harmony version number

Methods

getToolByName(){$.oTool}

openHarmony/openHarmony_application.js, line 402
get a tool by its name
Returns:
Type Description
$.oTool a oTool object representing the tool, or null if not found.

getValidStencils(tool){Array.<$.oStencil>}

openHarmony/openHarmony_application.js, line 416
returns the list of stencils useable by the specified tool
Name Type Description
tool $.oTool the tool object we want valid stencils for
Returns:
Type Description
Array.<$.oStencil> the list of stencils compatible with the specified tool

getWidgetByName(name, parentName){QWidget}

openHarmony/openHarmony_application.js, line 232
Gets access to a widget from the Harmony Interface.
Name Type Description
name string The name of the widget to look for.
parentName string optional The name of the parent widget to look into, in case of duplicates.
Returns:
Type Description
QWidget The widget if found, or null if it doesn't exist.

runMenuCommand(menuName, menuString)

openHarmony/openHarmony_application.js, line 427
Calls a function from one of the menus of Harmony. Doesn't support submenus at the moment. Doesn't work in batch mode.
Name Type Description
menuName string The name of the menu containing the action (must be a top level menu such as File, Edit etc)
menuString string The menu entry to trigger.