Documentation Center

Scope.declare

Description

Most scope variables that you want to set, get, or setListener for must first be declared. This is the method to declare your scope variables.

However, you should be aware that there are a few pre-defined scope variables such as showProperties and showCustomPanel. Therefore if you use the name of a pre-defined variable for one of your own variables then your should be aware that your code will supersede the built-in code.

Code example

Editor.getScope().declare("show-cleanup", false);
Editor.getScope().setListener("show-invisibles", showCleanup);

function showCleanup(show)
{
  var canvas = Editor.Canvas.getActiveCanvas();
  if (!canvas) return;
  canvas.setViewParam("show-cleanup", show);
}

Syntax

Scope.declare (variableName : String, initialValue : Boolean|Number|String|Object)

Arguments

variableName
String. The variable label.
initialValue
Boolean|Number|String|Object. An initial value.