diff --git a/web/app/3d/ui/ctrl.js b/web/app/3d/ui/ctrl.js index 3dbef7aa..1f2cd1e8 100644 --- a/web/app/3d/ui/ctrl.js +++ b/web/app/3d/ui/ctrl.js @@ -184,6 +184,7 @@ UI.prototype.registerWizard = function(wizard, overridingHistory) { wizard.apply = function() { craft.modify(wizard.createRequest(), overridingHistory); }; + wizard.focus(); return wizard; }; diff --git a/web/app/3d/wizards/box.js b/web/app/3d/wizards/box.js index 80513b1c..3bd4b32d 100644 --- a/web/app/3d/wizards/box.js +++ b/web/app/3d/wizards/box.js @@ -1,12 +1,11 @@ import {AXIS, IDENTITY_BASIS} from '../../math/l3space' import * as tk from '../../ui/toolkit.js' import {FACE_COLOR} from '../cad-utils' -import {addOkCancelLogic} from './wizard-commons' +import {addBehavior} from './wizard-commons' export function BoxWizard(viewer, initParams) { this.previewGroup = new THREE.Object3D(); this.viewer = viewer; - addOkCancelLogic(this); viewer.scene.add(this.previewGroup); this.previewGroup.add(this.box = this.createBox()); if (!initParams) { @@ -14,6 +13,7 @@ export function BoxWizard(viewer, initParams) { } this.ui = {}; this.createUI.apply(this, initParams); + addBehavior(this); this.synch(); } diff --git a/web/app/3d/wizards/extrude.js b/web/app/3d/wizards/extrude.js index 23d45fa7..d305b46e 100644 --- a/web/app/3d/wizards/extrude.js +++ b/web/app/3d/wizards/extrude.js @@ -3,18 +3,18 @@ import * as workbench from '../workbench' import * as cad_utils from '../cad-utils' import Vector from '../../math/vector' import {Matrix3, ORIGIN} from '../../math/l3space' -import {OpWizard, IMAGINE_MATERIAL, BASE_MATERIAL, addOkCancelLogic} from './wizard-commons' +import {OpWizard, IMAGINE_MATERIAL, BASE_MATERIAL, addBehavior} from './wizard-commons' export function ExtrudeWizard(app, face, invert, initParams) { OpWizard.call(this, app.viewer); this.app = app; this.face = face; this.invert = invert; - addOkCancelLogic(this); this.updatePolygons(); this.ui = {}; if (!initParams) initParams = ExtrudeWizard.DEFAULT_PARAMS; this.createUI.apply(this, initParams); + addBehavior(this); this.synch(); } diff --git a/web/app/3d/wizards/plane.js b/web/app/3d/wizards/plane.js index 471a1b45..00fb3dad 100644 --- a/web/app/3d/wizards/plane.js +++ b/web/app/3d/wizards/plane.js @@ -1,12 +1,11 @@ import {AXIS, IDENTITY_BASIS} from '../../math/l3space' import * as tk from '../../ui/toolkit.js' import {FACE_COLOR} from '../cad-utils' -import {addOkCancelLogic} from './wizard-commons' +import {addBehavior} from './wizard-commons' export function PlaneWizard(viewer, initParams) { this.previewGroup = new THREE.Object3D(); this.viewer = viewer; - addOkCancelLogic(this); viewer.scene.add(this.previewGroup); this.previewGroup.add(this.plane = this.createPlane()); this.operationParams = { @@ -18,6 +17,8 @@ export function PlaneWizard(viewer, initParams) { } this.ui = {}; this.createUI.apply(this, initParams); + addBehavior(this); + this.focus = () => this.ui.depth.input.focus(); this.synch(); } diff --git a/web/app/3d/wizards/shell.js b/web/app/3d/wizards/shell.js index 2fb1ee31..01915df5 100644 --- a/web/app/3d/wizards/shell.js +++ b/web/app/3d/wizards/shell.js @@ -16,7 +16,7 @@ ShellWizard.prototype.update = function(d) { }; ExtrudeWizard.prototype.updatePolygons = function() { - this.polygons = workbench.reconstructOutline(this.face.solid.csg, this.face); + this.polygons = [];//workbench.reconstructOutline(this.face.solid.csg, this.face); }; ShellWizard.prototype.createUI = function(d) { diff --git a/web/app/3d/wizards/sphere.js b/web/app/3d/wizards/sphere.js index f889e46f..a19c02c4 100644 --- a/web/app/3d/wizards/sphere.js +++ b/web/app/3d/wizards/sphere.js @@ -1,12 +1,11 @@ import {AXIS, IDENTITY_BASIS} from '../../math/l3space' import * as tk from '../../ui/toolkit.js' import {FACE_COLOR} from '../cad-utils' -import {addOkCancelLogic} from './wizard-commons' +import {addBehavior} from './wizard-commons' export function SphereWizard(viewer, initParams) { this.previewGroup = new THREE.Object3D(); this.viewer = viewer; - addOkCancelLogic(this); viewer.scene.add(this.previewGroup); this.previewGroup.add(this.sphere = this.createSphere()); if (!initParams) { @@ -14,6 +13,7 @@ export function SphereWizard(viewer, initParams) { } this.ui = {}; this.createUI.apply(this, initParams); + addBehavior(this); this.synch(); } diff --git a/web/app/3d/wizards/transform.js b/web/app/3d/wizards/transform.js index c2dfd85b..28e806f5 100644 --- a/web/app/3d/wizards/transform.js +++ b/web/app/3d/wizards/transform.js @@ -1,13 +1,12 @@ import {AXIS, IDENTITY_BASIS} from '../../math/l3space' import * as tk from '../../ui/toolkit.js' import {FACE_COLOR} from '../cad-utils' -import {addOkCancelLogic} from './wizard-commons' +import {addBehavior} from './wizard-commons' export function TransformWizard(viewer, solid, initParams) { this.previewGroup = new THREE.Object3D(); this.viewer = viewer; this.solid = solid; - addOkCancelLogic(this); if (!initParams) { initParams = TransformWizard.DEFAULT_PARAMS; } @@ -22,6 +21,7 @@ export function TransformWizard(viewer, solid, initParams) { this.transfomControlListener = tk.methodRef(this, "synchToUI"); this.viewer.transformControls.addEventListener( 'objectChange', this.transfomControlListener ); this.createUI.apply(this, initParams); + addBehavior(this); this.synch(); } diff --git a/web/app/3d/wizards/wizard-commons.js b/web/app/3d/wizards/wizard-commons.js index 2af9ef7b..1a652bd0 100644 --- a/web/app/3d/wizards/wizard-commons.js +++ b/web/app/3d/wizards/wizard-commons.js @@ -14,7 +14,7 @@ const BASE_MATERIAL = new THREE.LineBasicMaterial({ depthTest: false }); -function addOkCancelLogic(wizard) { +function addBehavior(wizard) { wizard.apply = function() {}; wizard.onCancel = function() {}; wizard.okClick = function() { @@ -25,6 +25,15 @@ function addOkCancelLogic(wizard) { this.onCancel(); this.dispose(); }; + wizard.ui.box.root.keydown((e) => { + switch (e.keyCode) { + case 27 : wizard.cancelClick(); break; + case 13 : wizard.okClick(); break; + } + }); + wizard.focus = () => { + wizard.ui.box.root.find('input, select').first().focus() + }; } function OpWizard(viewer) { @@ -56,4 +65,4 @@ OpWizard.prototype.dispose = function() { this.viewer.render(); }; -export {OpWizard, IMAGINE_MATERIAL, BASE_MATERIAL, addOkCancelLogic} \ No newline at end of file +export {OpWizard, IMAGINE_MATERIAL, BASE_MATERIAL, addBehavior} \ No newline at end of file