sb.cloneObject

sb.cloneObject(referenceObjectName, newObjectName, parentName, data)

Create a new control, table or group (newObjectName) within an existing parent (parentName) by copying all of the properties of an existing object (referenceObjectName). This new object will have all of the same actions, variables and it's current state will match the state of the reference object that is being copied. In the case of cloning groups, all of the reference group's controls will be cloned into the new group. Currently only controls and groups are supported as source reference objects.

  • Controls and tables can be cloned into either layer or group parents as long as no name conflict exists.

  • Groups can be cloned into layer parents as long as no name conflict exists. The data argument is a table of properties that match the properties for that type of object as described in the sb.setControlAttrs, sb.setTableAttrs or sb.setGroupAttrs functions as applicable. For example, most objects support x, y,hidden properties

Parameters:
    referenceObjectName       The name of the object to clone
    newObjectName             The new name of the object
    parentName                The name of the parent for the cloned object
    data                      Data to be set on the new cloned object
Example:

function createNewControl(context) {    
    var data = {["x"]:10, ["y"]:10};    
    sb.cloneObject("myControl", "myNewControl", "myLayer", data);
}
Was this article helpful?
0 out of 0 found this helpful