ImageGear .NET v25.0 - Updated
IPCC.MouseTools
API Reference > ViewerControl API > IPCC.MouseTools

Namespace: MouseTools

IPCC.MouseTools

The IPCC.MouseTools object allows you to create and get named mouse tools. This object encapsulates a collection of named mouse tools that are available to all viewer instances (globally). A mouse tool can be added to this collection using the IPCC.MouseTools.createMouseTool method, and a mouse tool in this collection can be accessed using the IPCC.MouseTools.getMouseTool method.

Methods

(static) createMouseTool(name, type) → {IPCC.MouseTool}

Create a new named mouse tool of a specific type. - If the new name matches the name of an existing mouse tool of the same type, then all properties of the existing tool will be overwritten with the defaults. Subsequent calls to `.getMouseTool(name)` will return the tool with the new properties. - If the new name already exists, but the type does not match, and error will be thrown.
Parameters:
Name Type Description
name string The name of the new mouse tool. This value is case-insensitive for comparison against existing mouse tools of the same name. **Note:** The case you provide will be persisted in the name property of the object that is returned, so it is best to pick a consistent naming scheme.
type string The type of the new mouse tool.
See:
Throws:
If calling this function using an existing `name` when the `type` does not match the already existing one.
Type
Error
Returns:
The MouseTool object that was created.
Type
IPCC.MouseTool
Example
// Create a new mouse tool with the name "MyLineAnnotationMouseTool"
var myMouseTool = IPCC.MouseTools.createMouseTool("MyLineAnnotationMouseTool", "LineAnnotation");

// Configure the mouse tool or the template mark of the mouse tool
myMouseTool.getTemplateMark().setOpacity(127);

// set the ViewerControl to use the mouse tool
viewerControl.setCurrentMouseTool("MyLineAnnotationMouseTool");

(static) getMouseTool(name) → {IPCC.MouseTool|undefined}

Gets a named mouse tool.
Parameters:
Name Type Description
name string The name of the `MouseTool` to get. This value is case-insensitive.
Returns:
The `MouseTool` object with the specified name, or `undefined`, if a `MouseTool` with the specified name does not exist.
Type
IPCC.MouseTool | undefined
Example
var mouseToolName = "FooMouseTool";

// get the mouse tool
var mouseTool = IPCC.MouseTools.getMouseTool(mouseToolName);

// check that the named mouse tool actually exists
if (mouseTool) {
    // do something with the MouseTool, you can do different things based on the type of the tool
    switch (mouseTool.getType()) {
        case IPCC.MouseTool.Type.LineAnnotation:
            ...
            break;
        default:
            ...
    }
}