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
typeThe type of tool event.
Values:
'mousedown','mouseup','mousemove','mousedrag'Type:
String
pointThe 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); }lastPointThe position of the mouse in project coordinates when the previous event was fired.
Type:
Point
downPointThe position of the mouse in project coordinates when the mouse button was last clicked.
Type:
Point
middlePointThe point in the middle between
lastPointandpoint. This is a useful position to use when creating artwork based on the moving direction of the mouse, as returned bydelta.Type:
Point
deltaThe 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
countThe number of times the mouse event was fired.
Type:
Number
itemThe item at the position of the mouse (if any).
If the item is contained within one or more
GrouporCompoundPathitems, 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
EventtimeStampThe time at which the event was created, in milliseconds since the epoch.
Read only.
Type:
Number
modifiersThe current state of the keyboard modifiers.
Read only.
Type:
object
See also:
Key.modifiers
Methods inherited from Event
EventpreventDefault()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() andpreventDefault().Any handler can also return
falseto indicate thatstop()should be called right after.
Was this helpful?