ToolEvent

Extends [Event](Event%20701eceeb8e6f49ec8a30675a8da31f48.md)

ToolEvent The ToolEvent object is received by the Tool’s mouse event handlers tool.onMouseDown, tool.onMouseDrag, tool.onMouseMove and tool.onMouseUp. The ToolEvent object is the only parameter passed to these functions and contains information about the mouse event.

Properties

  • type

    The type of tool event.

    • Values:

    • 'mousedown', 'mouseup', 'mousemove', 'mousedrag'

    • Type:

    • String

  • point

    The position of the mouse in project coordinates when the event was fired.

    • Type:

    • Point

    Example:

    function onMouseDrag(event) {
        // the position of the mouse when it is dragged
        console.log(event.point);
    }
    
    function onMouseUp(event) {
        // the position of the mouse when it is released
        console.log(event.point);
    }
  • lastPoint

    The position of the mouse in project coordinates when the previous event was fired.

    • Type:

    • Point

  • downPoint

    The position of the mouse in project coordinates when the mouse button was last clicked.

    • Type:

    • Point

  • middlePoint

    The point in the middle between lastPoint and point. This is a useful position to use when creating artwork based on the moving direction of the mouse, as returned by delta.

    • Type:

    • Point

  • delta

    The difference between the current position and the last position of the mouse when the event was fired. In case of the mouseup event, the difference to the mousedown position is returned.

    • Type:

    • Point

  • count

    The number of times the mouse event was fired.

    • Type:

    • Number

  • item

    The item at the position of the mouse (if any).

    If the item is contained within one or more Group or CompoundPath items, the most top level group or compound path that it is contained within is returned.

    • Type:

    • Item

Methods

  • toString()

    • Returns:

    • String — a string representation of the tool event

Properties inherited from Event

  • timeStamp

    The time at which the event was created, in milliseconds since the epoch.

    Read only.

    • Type:

      • Number

  • modifiers

    The current state of the keyboard modifiers.

    Read only.

    • Type:

      • object

    • See also:

      • Key.modifiers

Methods inherited from Event

  • preventDefault()

    Cancels the event if it is cancelable, without stopping further propagation of the event.

  • stopPropagation()

    Prevents further propagation of the current event.

  • stop()

    Cancels the event if it is cancelable, and stops stopping further propagation of the event. This is has the same effect as calling both stopPropagation() and preventDefault().

    Any handler can also return false to indicate that stop() should be called right after.