Sketcher: - Give focus to the MDI so that keyboard events are caught after starting edit. Else pressing ESC right after starting edit will not be caught to exit edit mode.

- After tool handler is purged, give back focus to MDI to make sure VPSketch receive the keyboard event. Else if user start a tool, dismiss it with ESC, then press ESC again to exit edit mode it won't be detected.
This commit is contained in:
PaddleStroke
2024-06-13 10:58:05 +02:00
committed by Chris Hennes
parent 1c865c0f95
commit b6f7fe8923

View File

@@ -632,8 +632,7 @@ void ViewProviderSketch::activateHandler(DrawSketchHandler* newHandler)
// make sure receiver has focus so immediately pressing Escape will be handled by
// ViewProviderSketch::keyPressed() and dismiss the active handler, and not the entire
// sketcher editor
Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView();
mdi->setFocus();
ensureFocus();
}
void ViewProviderSketch::deactivateHandler()
@@ -660,6 +659,9 @@ void ViewProviderSketch::purgeHandler()
viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
viewer->setSelectionEnabled(false);
}
// Give back the focus to the MDI to make sure VPSketch receive keyboard events.
ensureFocus();
}
void ViewProviderSketch::setAxisPickStyle(bool on)
@@ -700,9 +702,8 @@ void ViewProviderSketch::moveCursorToSketchPoint(Base::Vector2d point)
void ViewProviderSketch::ensureFocus()
{
Gui::MDIView* mdi = Gui::Application::Instance->activeDocument()->getActiveView();
mdi->setFocus();
mdi->setFocus();
}
void ViewProviderSketch::preselectAtPoint(Base::Vector2d point)
@@ -3140,6 +3141,10 @@ bool ViewProviderSketch::setEdit(int ModNum)
Workbench::enterEditMode();
// Give focus to the MDI so that keyboard events are caught after starting edit.
// Else pressing ESC right after starting edit will not be caught to exit edit mode.
ensureFocus();
return true;
}