Sketcher: Handling of right mouse button 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:
Abdullah Tahiri
2023-11-05 21:30:59 +01:00
committed by abdullahtahiriyo
parent 9cb6fa0df7
commit e235a1b795
4 changed files with 24 additions and 3 deletions

View File

@@ -437,6 +437,19 @@ public:
}
}
}
void pressRightButton(Base::Vector2d onSketchPos) override
{
Q_UNUSED(onSketchPos);
if (this->isFirstState()) {
quit();
}
else {
handleContinuousMode();
}
}
//@}

View File

@@ -378,6 +378,13 @@ void DrawSketchHandler::registerPressedKey(bool pressed, int key)
}
}
void DrawSketchHandler::pressRightButton(Base::Vector2d /*onSketchPos*/)
{
// the default behaviour is to quit - specific handler categories may
// override this behaviour, for example to implement a continuous mode
quit();
}
//**************************************************************************
// Helpers

View File

@@ -152,7 +152,8 @@ public:
{
return false;
}
virtual void registerPressedKey(bool /*pressed*/, int /*key*/);
virtual void registerPressedKey(bool pressed, int key);
virtual void pressRightButton(Base::Vector2d onSketchPos);
virtual void quit();

View File

@@ -1169,8 +1169,8 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
if (!pressed) {
switch (Mode) {
case STATUS_SKETCH_UseHandler:
// make the handler quit
sketchHandler->quit();
// delegate to handler whether to quit or do otherwise
sketchHandler->pressRightButton(Base::Vector2d(x, y));
return true;
case STATUS_NONE: {
// A right click shouldn't change the Edit Mode