diff --git a/src/Mod/Sketcher/Gui/DrawSketchController.h b/src/Mod/Sketcher/Gui/DrawSketchController.h index fc900f1a66..18d462be74 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchController.h +++ b/src/Mod/Sketcher/Gui/DrawSketchController.h @@ -578,6 +578,10 @@ protected: onViewIndexWithFocus = 0; configureOnViewParameters(); + + if (init) { + handler->moveCursorToSketchPoint(prevCursorPosition); + } } //@} diff --git a/src/Mod/Sketcher/Gui/DrawSketchDefaultHandler.h b/src/Mod/Sketcher/Gui/DrawSketchDefaultHandler.h index 52d2ce580c..62faadfeff 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchDefaultHandler.h +++ b/src/Mod/Sketcher/Gui/DrawSketchDefaultHandler.h @@ -427,6 +427,15 @@ public: if (key == SoKeyboardEvent::M && pressed && !this->isLastState()) { this->iterateToNextConstructionMethod(); } + else if (key == SoKeyboardEvent::ESCAPE && pressed) { + + if (this->isFirstState()) { + quit(); + } + else { + handleContinuousMode(); + } + } } //@} diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index d5ac7d55f4..3464ecfbdd 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -26,6 +26,8 @@ #include #include + +#include #endif // #ifndef _PreComp_ #include @@ -367,6 +369,15 @@ void DrawSketchHandler::toolWidgetChanged(QWidget* newwidget) onWidgetChanged(); } +void DrawSketchHandler::registerPressedKey(bool pressed, int key) +{ + // the default behaviour is to quit - specific handler categories may + // override this behaviour, for example to implement a continuous mode + if (key == SoKeyboardEvent::ESCAPE && !pressed) { + quit(); + } +} + //************************************************************************** // Helpers diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.h b/src/Mod/Sketcher/Gui/DrawSketchHandler.h index a41880c912..6e508465dc 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.h @@ -152,8 +152,7 @@ public: { return false; } - virtual void registerPressedKey(bool /*pressed*/, int /*key*/) - {} + virtual void registerPressedKey(bool /*pressed*/, int /*key*/); virtual void quit(); diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index d0910a8f58..e47bf294e4 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -690,8 +690,7 @@ bool ViewProviderSketch::keyPressed(bool pressed, int key) case SoKeyboardEvent::ESCAPE: { // make the handler quit but not the edit mode if (isInEditMode() && sketchHandler) { - if (!pressed) - sketchHandler->quit(); + sketchHandler->registerPressedKey(pressed, key); // delegate return true; } if (isInEditMode() && !drag.DragConstraintSet.empty()) {