2011-11-12 17:57:25 -05:00
|
|
|
/*
|
2013-01-28 21:03:27 -05:00
|
|
|
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
2011-11-12 17:57:25 -05:00
|
|
|
* http://paperjs.org/
|
|
|
|
*
|
2018-12-27 02:13:01 -05:00
|
|
|
* Copyright (c) 2011 - 2019, Juerg Lehni & Jonathan Puckey
|
2018-11-10 02:19:34 -05:00
|
|
|
* http://scratchdisk.com/ & https://puckey.studio/
|
2011-11-12 17:57:25 -05:00
|
|
|
*
|
|
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name MouseEvent
|
|
|
|
*
|
2012-12-23 10:01:53 -05:00
|
|
|
* @class The MouseEvent object is received by the {@link Item}'s mouse event
|
|
|
|
* handlers {@link Item#onMouseDown}, {@link Item#onMouseDrag},
|
2011-12-01 05:57:10 -05:00
|
|
|
* {@link Item#onMouseMove}, {@link Item#onMouseUp}, {@link Item#onClick},
|
|
|
|
* {@link Item#onDoubleClick}, {@link Item#onMouseEnter} and
|
|
|
|
* {@link Item#onMouseLeave}. The MouseEvent object is the only parameter passed
|
|
|
|
* to these functions and contains information about the mouse event.
|
|
|
|
*
|
2011-11-12 17:57:25 -05:00
|
|
|
* @extends Event
|
|
|
|
*/
|
2016-01-09 06:05:42 -05:00
|
|
|
/* global MouseEvent: true */
|
2013-05-27 15:48:58 -04:00
|
|
|
var MouseEvent = Event.extend(/** @lends MouseEvent# */{
|
2014-08-16 13:24:54 -04:00
|
|
|
_class: 'MouseEvent',
|
2013-06-23 23:18:32 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
initialize: function MouseEvent(type, event, point, target, delta) {
|
|
|
|
this.type = type;
|
2016-01-27 05:36:39 -05:00
|
|
|
this.event = event;
|
2014-08-16 13:24:54 -04:00
|
|
|
this.point = point;
|
2016-06-16 18:42:40 -04:00
|
|
|
this.target = target;
|
2014-08-16 13:24:54 -04:00
|
|
|
this.delta = delta;
|
|
|
|
},
|
2011-11-12 17:57:25 -05:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
/**
|
|
|
|
* The type of mouse event.
|
|
|
|
*
|
|
|
|
* @name MouseEvent#type
|
2016-01-08 14:45:54 -05:00
|
|
|
* @type String
|
|
|
|
* @values 'mousedown', 'mouseup', 'mousedrag', 'click', 'doubleclick',
|
2016-12-01 21:45:38 -05:00
|
|
|
* 'mousemove', 'mouseenter', 'mouseleave'
|
2014-08-16 13:24:54 -04:00
|
|
|
*/
|
2011-12-01 05:57:10 -05:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
/**
|
|
|
|
* The position of the mouse in project coordinates when the event was
|
|
|
|
* fired.
|
|
|
|
*
|
|
|
|
* @name MouseEvent#point
|
|
|
|
* @type Point
|
|
|
|
*/
|
2011-12-01 05:57:10 -05:00
|
|
|
|
2016-06-18 17:06:17 -04:00
|
|
|
/**
|
|
|
|
* The item that dispatched the event. It is different from
|
|
|
|
* {@link #currentTarget} when the event handler is called during
|
|
|
|
* the bubbling phase of the event.
|
|
|
|
*
|
|
|
|
* @name MouseEvent#target
|
|
|
|
* @type Item
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The current target for the event, as the event traverses the scene graph.
|
|
|
|
* It always refers to the element the event handler has been attached to as
|
|
|
|
* opposed to {@link #target} which identifies the element on
|
|
|
|
* which the event occurred.
|
|
|
|
*
|
|
|
|
* @name MouseEvent#currentTarget
|
|
|
|
* @type Item
|
|
|
|
*/
|
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
// DOCS: document MouseEvent#delta
|
|
|
|
/**
|
|
|
|
* @name MouseEvent#delta
|
|
|
|
* @type Point
|
|
|
|
*/
|
2011-12-01 05:57:10 -05:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
/**
|
|
|
|
* @return {String} a string representation of the mouse event
|
|
|
|
*/
|
|
|
|
toString: function() {
|
|
|
|
return "{ type: '" + this.type
|
|
|
|
+ "', point: " + this.point
|
2016-06-16 18:42:40 -04:00
|
|
|
+ ', target: ' + this.target
|
2014-08-16 13:24:54 -04:00
|
|
|
+ (this.delta ? ', delta: ' + this.delta : '')
|
|
|
|
+ ', modifiers: ' + this.getModifiers()
|
|
|
|
+ ' }';
|
|
|
|
}
|
2011-11-12 17:57:25 -05:00
|
|
|
});
|