@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
46 lines • 2.57 kB
JavaScript
import { InputHandlerType } from "./InputHandlerType";
import { InputManager } from "./../../Input/InputManager/InputManager";
import { Viewer } from "./../../Viewer";
import { ViewerCoordinatesConvertor } from "./../../Input/InputManager/ViewerCoordinatesConvertor";
import { HtmlInputManagerAdapter } from "./../../Input/InputManager/HtmlInputManagerAdapter";
import { InputHandlerFactory } from "./InputHandlerFactory";
import { isCompletableInputHandler } from "./../../Input/InputManager/ICompletableInputHandler";
export class InputHandlerManager {
constructor(_viewer, element, keyInputElement) {
this._viewer = _viewer;
this._onInputHandlerComplete = (result) => {
var _a;
this._viewer.eventManager.createInputHandlerFinishedEvent.notify(result);
if (((_a = this._setInputHandlerOptions) === null || _a === void 0 ? void 0 : _a.resetToDefaultInput) == null || this._setInputHandlerOptions.resetToDefaultInput)
this.setInputHandlerType(InputHandlerType.Default);
};
this._inputManager = new InputManager(new ViewerCoordinatesConvertor(this._viewer));
this._htmlInputMangerAdapter = new HtmlInputManagerAdapter(element, keyInputElement, this._inputManager, Viewer.preventKeyHandleClass, Viewer.preventClickHandleClass);
this._factory = new InputHandlerFactory(this._viewer, this._inputManager);
}
get inputManager() {
return this._inputManager;
}
get isDefault() {
return this._currentInputHandlerType === InputHandlerType.Default;
}
setInputHandlerType(type, args, options) {
var _a;
if (isCompletableInputHandler(this._currentInputHandler))
this._currentInputHandler.removeOnCompleted(this._onInputHandlerComplete);
this._setInputHandlerOptions = options;
this._currentInputHandlerType = type;
(_a = this._currentInputHandler) === null || _a === void 0 ? void 0 : _a.dispose();
this._currentInputHandler = this._factory.create(type, args);
if (isCompletableInputHandler(this._currentInputHandler))
this._currentInputHandler.addOnCompleted(this._onInputHandlerComplete);
this._viewer.canvas.updateButtonGroups();
}
dispose() {
var _a;
this._inputManager.dispose();
this._htmlInputMangerAdapter.dispose();
(_a = this._currentInputHandler) === null || _a === void 0 ? void 0 : _a.dispose();
}
}
//# sourceMappingURL=InputHandlerManager.js.map