| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
- export class ViewUserInputEvents {
- constructor(coordinatesConverter) {
- this.onKeyDown = null;
- this.onKeyUp = null;
- this.onContextMenu = null;
- this.onMouseMove = null;
- this.onMouseLeave = null;
- this.onMouseDown = null;
- this.onMouseUp = null;
- this.onMouseDrag = null;
- this.onMouseDrop = null;
- this.onMouseDropCanceled = null;
- this.onMouseWheel = null;
- this._coordinatesConverter = coordinatesConverter;
- }
- emitKeyDown(e) {
- var _a;
- (_a = this.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(this, e);
- }
- emitKeyUp(e) {
- var _a;
- (_a = this.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(this, e);
- }
- emitContextMenu(e) {
- var _a;
- (_a = this.onContextMenu) === null || _a === void 0 ? void 0 : _a.call(this, this._convertViewToModelMouseEvent(e));
- }
- emitMouseMove(e) {
- var _a;
- (_a = this.onMouseMove) === null || _a === void 0 ? void 0 : _a.call(this, this._convertViewToModelMouseEvent(e));
- }
- emitMouseLeave(e) {
- var _a;
- (_a = this.onMouseLeave) === null || _a === void 0 ? void 0 : _a.call(this, this._convertViewToModelMouseEvent(e));
- }
- emitMouseDown(e) {
- var _a;
- (_a = this.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(this, this._convertViewToModelMouseEvent(e));
- }
- emitMouseUp(e) {
- var _a;
- (_a = this.onMouseUp) === null || _a === void 0 ? void 0 : _a.call(this, this._convertViewToModelMouseEvent(e));
- }
- emitMouseDrag(e) {
- var _a;
- (_a = this.onMouseDrag) === null || _a === void 0 ? void 0 : _a.call(this, this._convertViewToModelMouseEvent(e));
- }
- emitMouseDrop(e) {
- var _a;
- (_a = this.onMouseDrop) === null || _a === void 0 ? void 0 : _a.call(this, this._convertViewToModelMouseEvent(e));
- }
- emitMouseDropCanceled() {
- var _a;
- (_a = this.onMouseDropCanceled) === null || _a === void 0 ? void 0 : _a.call(this);
- }
- emitMouseWheel(e) {
- var _a;
- (_a = this.onMouseWheel) === null || _a === void 0 ? void 0 : _a.call(this, e);
- }
- _convertViewToModelMouseEvent(e) {
- if (e.target) {
- return {
- event: e.event,
- target: this._convertViewToModelMouseTarget(e.target)
- };
- }
- return e;
- }
- _convertViewToModelMouseTarget(target) {
- return ViewUserInputEvents.convertViewToModelMouseTarget(target, this._coordinatesConverter);
- }
- static convertViewToModelMouseTarget(target, coordinatesConverter) {
- const result = Object.assign({}, target);
- if (result.position) {
- result.position = coordinatesConverter.convertViewPositionToModelPosition(result.position);
- }
- if (result.range) {
- result.range = coordinatesConverter.convertViewRangeToModelRange(result.range);
- }
- return result;
- }
- }
|