Sg2.9
Tool
Packages RSS

The Tool object refers to the Scriptographer tool in the Illustrator tool palette and can be accessed through the global tool variable. All its properties are also available in the global scope.

The global tool variable only exists in scripts that contain mouse handler functions (onMouseDown, onMouseDrag, onMouseUp), which are automatically associated with the tool button on execution.

Sample code:

var path;

// Only execute onMouseDrag when the mouse
// has moved at least 10 points:
tool.distanceThreshold = 10;

function onMouseDown(event) {
	// Create a new path every time the mouse is clicked
	path = new Path();
}

function onMouseDrag(event) {
	// Add a point to the path every time the mouse is dragged
	path.lineTo(event.point);
}

Operators

Properties

Tool Button Styling

Mouse Event Handlers

Tool Button Event Handlers

Functions