Skip to content
Snippets Groups Projects
Commit 6caf1ca6 authored by hertzhaft's avatar hertzhaft
Browse files

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

parent 7f9b4689
Branches
Tags
No related merge requests found
......@@ -45,6 +45,8 @@
var geom = null;
// convenience variable, set in init()
var CSS = '';
// shape currently being drawn/dragged
var currentShape;
// current key state: keystate[event.key] = event
var keystate = {};
// shiftPressed = event.shiftKey;
......@@ -815,6 +817,7 @@
// event handler for positionShape
var onPositionShape = function(event, shape) {
var data = this;
currentShape = shape;
if (keystate['x'] != null) { // change only x-Dimension of mouse pointer
manipulatePosition(shape, lockDimension('y'));
}
......@@ -835,6 +838,7 @@
var onChangeShape = function(event, shape) {
var data = this;
updateInfo(data, shape);
currentShape = null;
_debug_shape('onChangeShape', shape);
};
......@@ -1124,12 +1128,22 @@
var onKeyDown = function(event, data) {
var code = event.keyCode;
var key = event.key;
keystate[key] = event; // save key state on key
// delete selected shapes
if (code === 46 || key === 'Delete') {
removeSelectedShapes(data);
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);
};
......
......@@ -470,7 +470,7 @@
delete shape.$elem;
}
};
/**
* return a vertexDragHandler function.
*
......@@ -508,9 +508,9 @@
var dragMove = function (evt) { // dragging
var pt = geom.position(evt);
pt.clipTo(imgRect);
shape.properties.screenpos[vtx] = pt;
$(data).trigger('positionShape', shape);
pt.clipTo(imgRect);
// move handle
$handle.attr({'x': pt.x-hs/2, 'y': pt.y-hs/2});
// update shape SVG element
......
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