Commit 6caf1ca6 authored by hertzhaft's avatar hertzhaft

immediate reaction on when dragging and keys x or y are pressed

parent 7f9b4689
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
var geom = null; var geom = null;
// convenience variable, set in init() // convenience variable, set in init()
var CSS = ''; var CSS = '';
// shape currently being drawn/dragged
var currentShape;
// current key state: keystate[event.key] = event // current key state: keystate[event.key] = event
var keystate = {}; var keystate = {};
// shiftPressed = event.shiftKey; // shiftPressed = event.shiftKey;
...@@ -815,6 +817,7 @@ ...@@ -815,6 +817,7 @@
// event handler for positionShape // event handler for positionShape
var onPositionShape = function(event, shape) { var onPositionShape = function(event, shape) {
var data = this; var data = this;
currentShape = shape;
if (keystate['x'] != null) { // change only x-Dimension of mouse pointer if (keystate['x'] != null) { // change only x-Dimension of mouse pointer
manipulatePosition(shape, lockDimension('y')); manipulatePosition(shape, lockDimension('y'));
} }
...@@ -835,6 +838,7 @@ ...@@ -835,6 +838,7 @@
var onChangeShape = function(event, shape) { var onChangeShape = function(event, shape) {
var data = this; var data = this;
updateInfo(data, shape); updateInfo(data, shape);
currentShape = null;
_debug_shape('onChangeShape', shape); _debug_shape('onChangeShape', shape);
}; };
...@@ -1124,12 +1128,22 @@ ...@@ -1124,12 +1128,22 @@
var onKeyDown = function(event, data) { var onKeyDown = function(event, data) {
var code = event.keyCode; var code = event.keyCode;
var key = event.key; var key = event.key;
keystate[key] = event; // save key state on key
// delete selected shapes // delete selected shapes
if (code === 46 || key === 'Delete') { if (code === 46 || key === 'Delete') {
removeSelectedShapes(data); removeSelectedShapes(data);
return false; return false;
} }
keystate[key] = event; // save key state on key // keys 'x' and 'y': immediate response, lock dimension and redraw shape
if (code === 88 || key === 'x' ||
code === 89 || key === 'y') {
if (currentShape == null) { return true };
var props = currentShape.properties;
var pt = props.screenpos[props.vtx]; // get last recorded mouse position
var eventpos = { pageX: pt.x, pageY: pt.y }
var evt = jQuery.Event("mousemove.dlVertexDrag", eventpos);
$(document).trigger(evt);
}
// console.debug('measure: keyDown', code, event.key, keystate); // console.debug('measure: keyDown', code, event.key, keystate);
}; };
......
...@@ -508,9 +508,9 @@ ...@@ -508,9 +508,9 @@
var dragMove = function (evt) { // dragging var dragMove = function (evt) { // dragging
var pt = geom.position(evt); var pt = geom.position(evt);
pt.clipTo(imgRect);
shape.properties.screenpos[vtx] = pt; shape.properties.screenpos[vtx] = pt;
$(data).trigger('positionShape', shape); $(data).trigger('positionShape', shape);
pt.clipTo(imgRect);
// move handle // move handle
$handle.attr({'x': pt.x-hs/2, 'y': pt.y-hs/2}); $handle.attr({'x': pt.x-hs/2, 'y': pt.y-hs/2});
// update shape SVG element // update shape SVG element
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment