Controller Class Reference

The Controller JavaScript object. This object is available in Master Controller callback functions. More...

Properties

String name
 The object type "__master_controller_object__". More...
 
String node
 The node path to the Master Controller node ex: "Top/MyMasterController". More...
 
QScriptValue controls
 The script widget array. More...
 
QScriptValue data
 

Controller callback functions

QScriptValue onShowControl
 Called when the user shows the Master Controller node controls. More...
 
QScriptValue onHideControl
 Called when the user hides the Master Controller node controls. More...
 
QScriptValue onFrameChanged
 Called when the current frame of the application changes. More...
 

Detailed Description

The Controller JavaScript object. This object is available in Master Controller callback functions.

Controller is created and added to the scripting environment of the master controller and allows the script running in that context to do a variety of tasks, such as:

  • Register script widgets.
  • Get the parent node path.
  • Create callback function to certain events.

The Controller object is only available in its callback functions like onShowControl or onFrameChanged. However, it is possible to store a reference to it in the global scope of the Master Controller script.

var myController = Controller; // Capture the Controller
function sliderValueChanged(newSliderValue)
{
// Use the captured Controller here.
var layerSpacing = node.getAttr(myController.node, frame.current(), "Layer_Spacing").doubleValue();
repositionNodes(layerSpacing);
}
// The Controller object is available in its callback functions.
{
Controller.controls.push(new SliderWidget({data : "myAttribute"}));
Controller.controls.push(new SliderWidget({xmin : 4}));
Controller.controls[0].valueChanged.connect(sliderValueChanged);
}
{
MessageLog("Number of controls " + Controller.controls.length);
}
{
// Synchronize the 2 sliders values on frame change.
var value = node.getAttr(Controller.node, frame.current(), "myAttribute").doubleValue();
Controller.controls[1].data().setValue(value);
}

Property Documentation

◆ controls

QScriptValue Controller::controls
readwrite

The script widget array.

// Use the standard default value.
Controller.controls[0].data().setValue(25);
Controller.controls[1].data().setValue(60);

◆ data

QScriptValue Controller::data
readwrite

◆ name

String Controller::name
read

The object type "__master_controller_object__".

◆ node

String Controller::node
read

The node path to the Master Controller node ex: "Top/MyMasterController".

var myController = Controller; // Capture the Controller to be able to use it elsewhere than in its callback functions.
function sliderValueChanged(newSliderValue)
{
var myOtherWidgetValue = node.getAttr(myController.node, frame.current(), "MyOtherSlider").doubleValue();
// ...
}

◆ onFrameChanged

QScriptValue Controller::onFrameChanged
readwrite

Called when the current frame of the application changes.

{
var value = 100 * (node.getAttr("Top/MyPeg", frame.current(), "POSITION.X").doubleValue() + 1) / 2;
myController.controls[0].data().setValue(value);
}

◆ onHideControl

QScriptValue Controller::onHideControl
readwrite

Called when the user hides the Master Controller node controls.

{
MessageLog.trace("Hide the script widget");
}

◆ onShowControl

QScriptValue Controller::onShowControl
readwrite

Called when the user shows the Master Controller node controls.

{
// Create the controls array
// Create a 2d point widget.
Controller.controls[0].valueChanged.connect(point2dValueChanged);
}