Sketcher: Handling of ESC keypress during handler execution
=========================================================== Instead of terminating the handler, as mandated before this PR by ViewProviderSketch, ViewProviderSketch delegates the action to DrawSketchHandler. DrawSketchHandler implements by default this terminating behaviour, but allows to override it. DrawSketchDefaultHandler (and all tools deriving from it) implement as default behaviour to cancel if in initial state, otherwise to reset.
This commit is contained in:
committed by
abdullahtahiriyo
parent
fc472601e4
commit
9cb6fa0df7
@@ -578,6 +578,10 @@ protected:
|
||||
onViewIndexWithFocus = 0;
|
||||
|
||||
configureOnViewParameters();
|
||||
|
||||
if (init) {
|
||||
handler->moveCursorToSketchPoint(prevCursorPosition);
|
||||
}
|
||||
}
|
||||
//@}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
//@}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QPainter>
|
||||
|
||||
#include <Inventor/events/SoKeyboardEvent.h>
|
||||
#endif // #ifndef _PreComp_
|
||||
|
||||
#include <Base/Console.h>
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -152,8 +152,7 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual void registerPressedKey(bool /*pressed*/, int /*key*/)
|
||||
{}
|
||||
virtual void registerPressedKey(bool /*pressed*/, int /*key*/);
|
||||
|
||||
virtual void quit();
|
||||
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user