=== modified file 'src/ui/tool/control-point-selection.cpp' --- src/ui/tool/control-point-selection.cpp 2011-11-04 21:30:19 +0000 +++ src/ui/tool/control-point-selection.cpp 2012-01-22 11:59:48 +0000 @@ -290,6 +290,8 @@ void ControlPointSelection::_pointDragged(Geom::Point &new_pos, GdkEventMotion *event) { + if (!_dragging) return; + Geom::Point abs_delta = new_pos - _original_positions[_grabbed_point]; double fdist = Geom::distance(_original_positions[_grabbed_point], _original_positions[_farthest_point]); if (held_only_alt(*event) && fdist > 0) { @@ -351,6 +353,24 @@ signal_update.emit(); } +void ControlPointSelection::_pointDragCancelled() +{ + if (!_dragging) return; + + // Move the points back to original position + for (iterator i = _points.begin(); i != _points.end(); ++i) { + SelectableControlPoint *cur = (*i); + cur->move(_original_positions[cur]); + } + _original_positions.clear(); + _last_trans.clear(); + _dragging = false; + _grabbed_point = _farthest_point = NULL; + _updateBounds(); + restoreTransformHandles(); + signal_update.emit(); +} + void ControlPointSelection::_pointUngrabbed() { _original_positions.clear(); === modified file 'src/ui/tool/control-point-selection.h' --- src/ui/tool/control-point-selection.h 2011-09-16 23:00:05 +0000 +++ src/ui/tool/control-point-selection.h 2012-01-22 05:16:21 +0000 @@ -121,6 +121,7 @@ // creates problems when dragging a point that was not selected. void _pointGrabbed(SelectableControlPoint *); void _pointDragged(Geom::Point &, GdkEventMotion *); + void _pointDragCancelled(); void _pointUngrabbed(); bool _pointClicked(SelectableControlPoint *, GdkEventButton *); void _pointChanged(SelectableControlPoint *, bool); === modified file 'src/ui/tool/control-point.cpp' --- src/ui/tool/control-point.cpp 2012-01-12 01:59:22 +0000 +++ src/ui/tool/control-point.cpp 2012-01-22 08:47:37 +0000 @@ -108,6 +108,7 @@ bool ControlPoint::_drag_initiated = false; bool ControlPoint::_event_grab = false; +bool ControlPoint::_drag_cancelled = false; /** A color set which you can use to create an invisible control that can still receive events. * @relates ControlPoint */ @@ -358,6 +359,7 @@ // this guarantees smooth redraws while dragging _desktop->canvas->forceFullRedrawAfterInterruptions(5); _drag_initiated = true; + _drag_cancelled = false; } } if (!transferred) { @@ -437,10 +439,22 @@ break; // update tips on modifier state change - // TODO add ESC keybinding as drag cancel case GDK_KEY_PRESS: switch (get_group0_keyval(&event->key)) { + case GDK_Escape: + {// Cancel a drag if Esc is pressed + if (_drag_initiated) { + _drag_cancelled = true; + ungrabbed(NULL); + sp_canvas_item_ungrab(_canvas_item, event->button.time); + _event_grab = false; + //_drag_initiated = false; + _desktop->canvas->endForcedFullRedraws(); + _drag_cancelled = false; + } + break; + } case GDK_Tab: {// Downcast from ControlPoint to TransformHandle, if possible // This is an ugly hack; we should have the transform handle intercept the keystrokes itself === modified file 'src/ui/tool/control-point.h' --- src/ui/tool/control-point.h 2011-10-05 07:06:08 +0000 +++ src/ui/tool/control-point.h 2012-01-22 07:50:32 +0000 @@ -157,6 +157,7 @@ SPCanvasItem * _canvas_item; ///< Visual representation of the control point. ColorSet *_cset; ///< Colors used to represent the point State _state; + static bool _drag_cancelled; static int const _grab_event_mask; static Geom::Point const &_last_click_event_point() { return _drag_event_origin; } === modified file 'src/ui/tool/node.cpp' --- src/ui/tool/node.cpp 2012-01-14 13:35:29 +0000 +++ src/ui/tool/node.cpp 2012-01-22 08:44:37 +0000 @@ -350,6 +350,11 @@ void Handle::ungrabbed(GdkEventButton *event) { + if (_drag_cancelled) { + move(_last_drag_origin()); + _pm().update(); + } + // hide the handle if it's less than dragtolerance away from the node // TODO is this actually desired? Inkscape::Preferences *prefs = Inkscape::Preferences::get(); === modified file 'src/ui/tool/selectable-control-point.cpp' --- src/ui/tool/selectable-control-point.cpp 2010-11-17 02:12:56 +0000 +++ src/ui/tool/selectable-control-point.cpp 2012-01-22 07:30:19 +0000 @@ -70,7 +70,10 @@ void SelectableControlPoint::ungrabbed(GdkEventButton *) { - _selection._pointUngrabbed(); + if (_drag_cancelled) + _selection._pointDragCancelled(); + else + _selection._pointUngrabbed(); } bool SelectableControlPoint::clicked(GdkEventButton *event)