UNPKG

pencil.js

Version:

Nice modular interactive 2D drawing library.

182 lines (181 loc) 5.61 kB
/** * @module MouseEvent */ /** * Mouse event class * @class * @extends {module:BaseEvent} */ export default class MouseEvent { /** * @typedef {Object} MouseButtons * @prop {String} left - Left button on a classic right-handed mouse * @prop {String} main - Main button * @prop {String} wheel - The scroll wheel * @prop {String} middle - Middle button, usually the scroll wheel * @prop {String} right - Right button on a classic right-handed mouse * @prop {String} secondary - Secondary button * @prop {String} backward - Browse backward button * @prop {String} aux1 - First auxiliary button, usually the browse backward button * @prop {String} forward - Browse forward button * @prop {String} aux2 - Second auxiliary button, usually the browse forward button */ /** * Set of buttons on a pointing device for easy access * @example scene.on(`${MouseEvent.events.down}.${MouseEvent.buttons.middle}`, () => { * console.log("User pressed the middle mouse button"); * }); * @return {MouseButtons} */ static get buttons(): { /** * - Left button on a classic right-handed mouse */ left: string; /** * - Main button */ main: string; /** * - The scroll wheel */ wheel: string; /** * - Middle button, usually the scroll wheel */ middle: string; /** * - Right button on a classic right-handed mouse */ right: string; /** * - Secondary button */ secondary: string; /** * - Browse backward button */ backward: string; /** * - First auxiliary button, usually the browse backward button */ aux1: string; /** * - Browse forward button */ forward: string; /** * - Second auxiliary button, usually the browse forward button */ aux2: string; }; /** * @typedef {Object} MouseEvents * @prop {String} down - Mouse button is pressed * @prop {String} up - Mouse button is released * @prop {String} click - Mouse button is pressed then released without moving * @prop {String} move - Mouse is moved * @prop {String} hover - Mouse goes hover a component * @prop {String} leave - Mouse leave a component * @prop {String} wheel - Mouse wheel is scrolled in any direction * @prop {String} scrollDown - Mouse wheel is scrolled down * @prop {String} scrollUp - Mouse wheel is scrolled up * @prop {String} zoomOut - Mouse wheel is scrolled down (away from the screen) * @prop {String} zoomIn - Mouse wheel is scrolled up (toward the screen) * @prop {String} grab - Mouse is clicked on a draggable component * @prop {String} drag - Mouse is moved while grabbing a component * @prop {String} drop - Mouse is release after dragging a component * @prop {String} resize - Mouse is moved while holding the handle of a resizable component * @prop {String} rotate - Mouse is rotating a component * @prop {String} doubleClick - Mouse is clicked twice rapidly */ /** * Set of events for easy access * @type {MouseEvents} */ static get events(): { /** * - Mouse button is pressed */ down: string; /** * - Mouse button is released */ up: string; /** * - Mouse button is pressed then released without moving */ click: string; /** * - Mouse is moved */ move: string; /** * - Mouse goes hover a component */ hover: string; /** * - Mouse leave a component */ leave: string; /** * - Mouse wheel is scrolled in any direction */ wheel: string; /** * - Mouse wheel is scrolled down */ scrollDown: string; /** * - Mouse wheel is scrolled up */ scrollUp: string; /** * - Mouse wheel is scrolled down (away from the screen) */ zoomOut: string; /** * - Mouse wheel is scrolled up (toward the screen) */ zoomIn: string; /** * - Mouse is clicked on a draggable component */ grab: string; /** * - Mouse is moved while grabbing a component */ drag: string; /** * - Mouse is release after dragging a component */ drop: string; /** * - Mouse is moved while holding the handle of a resizable component */ resize: string; /** * - Mouse is rotating a component */ rotate: string; /** * - Mouse is clicked twice rapidly */ doubleClick: string; }; /** * MouseEvent constructor * @param {String} name - Name of the event * @param {EventEmitter} target - Component concerned by the event * @param {PositionDefinition} positionDefinition - Position of the mouse when event trigger * @param {UIEvent} [event] - Original HTML event */ constructor(name: string, target: EventEmitter, positionDefinition: PositionDefinition, event?: UIEvent); position: Position; button: any; /** * @inheritDoc */ getModifier(): any; } import Position from "@pencil.js/position";