paper.js/src/ui/MouseEvent.js

76 lines
1.8 KiB
JavaScript
Raw Normal View History

/*
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
*
* Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
*
* 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},
* {@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.
*
* @extends Event
*/
var MouseEvent = Event.extend(/** @lends MouseEvent# */{
_class: 'MouseEvent',
initialize: function MouseEvent(type, event, point, target, delta) {
Event.call(this, event);
2011-11-16 16:54:03 -05:00
this.type = type;
this.point = point;
this.target = target;
this.delta = delta;
2011-11-16 16:54:03 -05:00
},
2011-11-16 16:54:03 -05:00
/**
* The type of mouse event.
*
* @name MouseEvent#type
* @type String('mousedown', 'mouseup', 'mousedrag', 'click',
* 'doubleclick', 'mousemove', 'mouseenter', 'mouseleave')
*/
/**
* The position of the mouse in project coordinates when the event was
* fired.
*
* @name MouseEvent#point
* @type Point
*/
// DOCS: document MouseEvent#target
/**
* @name MouseEvent#target
* @type Item
*/
// DOCS: document MouseEvent#delta
/**
* @name MouseEvent#delta
* @type Point
*/
/**
2013-08-23 22:45:28 -04:00
* @return {String} a string representation of the mouse event
2011-11-16 16:54:03 -05:00
*/
toString: function() {
2012-12-08 22:57:04 -05:00
return "{ type: '" + this.type
+ "', point: " + this.point
2011-11-16 16:54:03 -05:00
+ ', target: ' + this.target
+ (this.delta ? ', delta: ' + this.delta : '')
2011-11-16 16:54:03 -05:00
+ ', modifiers: ' + this.getModifiers()
+ ' }';
}
});