Setting the Properties of a Master Controller Widget
T-HSCP-002-005
When creating a widget, you can customize it by declaring its properties. These properties can be passed as parameters in the constructor of the widget. For example, the following code creates a Slider widget with a full set of custom properties:
Controller.controls.push(new SliderWidget(
{
data : "mySlider", // name of the created attribute
width : 0.15, // width of the slider frame
height : 0.2, // height of the slider frame
min : 0, // minimum value of the slider
max : 100, // maximum value of the slider
frame_color : ColorRGBA(40,100,150), // the colour of the slider frame
slider_color : ColorRGBA(135,135,135), // the colour of the slider handle
slider_selection_color : ColorRGBA(200,200,150), // the colour of the slider frame when selected
}));
The data property of a widget can be set to a string that uniquely identifies its attributes. Hence, if two widgets are created with an identical data property, they will have the same attribute, like in this example:
// Create a 2d point widget.
Controller.controls.push(new Point2dWidget(
{
data : "Magnet", // name of the created attribute
size : 0.05, // the diameter of the point
selection_color : ColorRGBA(80,50,50) // the colour of the point manipulator when selected.
}));
// Create a 2d point widget.
Controller.controls.push(new Point2dWidget(
{
data : "Magnet", // name of the created attribute
size : 0.1, // the diameter of the point
selection_color : ColorRGBA(20,70,70) // the colour of the point manipulator when selected.
}));
Each type of Master Controller widget has its own set of properties that can be set at its creation. All of their properties are optional and have default values if not set.
NOTE To learn about the properties of each type of widget, refer to the Master Controller Node section of the Harmony scripting reference–see Harmony Scripting Reference .