Skip to main content
Version: 9.0.2

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

ParameterTypeDescription
referenceObjectNamestringThe name of the object to clone.
newObjectNamestringThe new name of the object.
parentNamestringThe name of the parent for the cloned object.
dataobjectData to be set on the new cloned object.

Example

function createNewControl(context) {
var data = {["x"]:10, ["y"]:10};
sb.cloneObject("myControl", "myNewControl", "myLayer", data);
}