mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-07 17:04:58 +01:00
handle esc/enter for wizards
This commit is contained in:
parent
7b1a31deec
commit
fd92fe5f1e
8 changed files with 24 additions and 13 deletions
|
|
@ -184,6 +184,7 @@ UI.prototype.registerWizard = function(wizard, overridingHistory) {
|
|||
wizard.apply = function() {
|
||||
craft.modify(wizard.createRequest(), overridingHistory);
|
||||
};
|
||||
wizard.focus();
|
||||
return wizard;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
export {OpWizard, IMAGINE_MATERIAL, BASE_MATERIAL, addBehavior}
|
||||
Loading…
Reference in a new issue