# Class: SignatureCreateTool

## Tools. SignatureCreateTool

Represents the tool for creating a Signature which is represented by an Annotations.FreeHandAnnotation.

#### new SignatureCreateTool(docViewer)

  Creates a new instance of the SignatureCreateTool.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `docViewer` | CoreControls.DocumentViewer | an instance of DocumentViewer.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `ctx` | CanvasRenderingContext2D | The signature canvas context
  `freeHandAnnot` | Annotations.FreeHandAnnotation | The underlying annotation used by the tool
  `setTextHandler` | function | Sets the function that defines the value of the "sign here" text

### Extends

- Tools.Tool

### Methods

#### addDefaultSignature()

  Adds the default signature to the document.

#### addSignature(makeDefault)

  Add the signature to the document.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `makeDefault` | boolean | Whether to make this signature the default signature

  ##### Returns:

  Whether the signature was added. Will return false if there are no paths drawn.

  Type
    boolean

#### clearLocation()

  Clear the location which is set when a mouse click is performed

#### clearSignatureCanvas()

  Clears the signature canvas.

#### contextMenu(e)

  The function called when a context menu should be shown. Use e.preventDefault to disable the default browser context menu

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `e` |  | the event object

  Inherited From:
    - Tools.Tool#contextMenu

#### drawBackground()

  Draws the background on the signature canvas. Override this function for a custom background.

#### getDocumentViewer()

  Returns the instance of DocumentViewer for this tool.

  Inherited From:
    - Tools.Tool#getDocumentViewer

  ##### Returns:

  the instance of DocumentViewer for this tool.

  Type
    CoreControls.DocumentViewer

#### getMouseLocation(e)

  Takes an event object from a mouse event and converts the location into window coordinates

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `e` |  | the event object containing mouse coordinates

  Inherited From:
    - Tools.Tool#getMouseLocation

#### hasDefaultSignature()

  Checks if a default signature has been assigned.

  ##### Returns:

  The default signature data is an array of arrays

  Type
    Array.<Array>

#### hasLocation()

  Returns if the signature tool has any location to draw the signature

  ##### Returns:

  Type
    boolean

#### initAnnot()

  Initializes the underlying annotation for the signature. Can be extended to customize the appearance of the signature.

#### initDefaultSignature(paths)

  Initialize the default signature.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `paths` | Array.<Array> | Expects an array of arrays where each array corresponds to a path and each object in the array is an object with an x and y property

#### isEmptySignature()

  Checks if there are any paths drawn. Returns true if there are no paths.

  ##### Returns:

  If number of drawn paths is 0.

  Type
    boolean

#### keyDown(e)

  The function called when a keyboard key is down.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `e` |  | the event object containing keyboard key data.

  Inherited From:
    - Tools.Tool#keyDown

#### mouseDoubleClick(e)

  The function called when the mouse left button is double clicked.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `e` |  | the event object containing mouse coordinates.

  Inherited From:
    - Tools.Tool#mouseDoubleClick

#### mouseLeftDown(e)

  The function called when the left mouse button is down

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `e` |  | the event object containing mouse coordinates.

  Inherited From:
    - Tools.Tool#mouseLeftDown

#### mouseLeftUp(e)

  The function called when the left mouse button is up. Typically, annotations are created and added to the annotation manager at this point.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `e` |  | the event object containing mouse coordinates.

  Inherited From:
    - Tools.Tool#mouseLeftUp

#### mouseMove(e)

  The function called when the mouse moves.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `e` |  | the event object containing mouse coordinates.

  Inherited From:
    - Tools.Tool#mouseMove

#### openSignature()

  Notify the signature tool that the signature is being viewed.

#### setName(name)

  Set the name of the tool, which can be accessed by toolObject.name

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `name` | string | name of the tool

  Inherited From:
    - Tools.Tool#setName

#### setSignatureCanvas(canvas)

  Sets the canvas to be used by the signature tool.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `canvas` | canvas | The canvas that the signature tool uses to draw on.

#### setStyles(callback)

  Set the style for the tool, which will be applied to annotations drawn afterwards

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` |  | callback function that returns new style object from old style object argument.

  Inherited From:
    - Tools.Tool#setStyles

#### switchIn(oldTool)

  The function called when this tool is selected. Typically use for changing mouse cursors, and initializing states for the tool.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `oldTool` | Tools.Tool | the Tool class that was previously selected.

  Inherited From:
    - Tools.Tool#switchIn

#### switchOut(newTool)

  The function called when this tool is deselected. Typically use for changing mouse cursors, and cleaning up states for the tool.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `newTool` | Tools.Tool | the Tool class that was newly selected.

  Inherited From:
    - Tools.Tool#switchOut

### Events

#### annotationAdded

  Triggered when an annotation has been added to the document by the tool

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `evt` | object | Event object
  `annotation` | Annotations.Annotation | The annotation that was added

#### locationSelected

  Triggered when a page location has been clicked on by the tool

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `evt` | object | Event object
  `pageCoordinates` | Tools.PageCoordinate | Indicates where the tool clicked

#### saveDefault

  Triggered when the tool saves a signature as the default

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `evt` | object | Event object
  `paths` | Array.<Array> | An array of arrays that contains the coordinates of the signature points

#### Search results