Fix B-spline keyboard focus issue (#23859) (#23860)

* Fix B-spline keyboard focus issue (#23859)

- Restore keyboard focus after command restart in changeConstructionMethode()
- Fixes M key mode switching and R toggle periodic functionality
- Uses direct MDI view focus restoration instead of private ensureFocus() method

Fixes issue where keyboard shortcuts stop working after first mode switch.

* Address Copilot feedback: Add null check for activeDocument()

- Use ternary operator for cleaner null safety
- Prevents potential crash if activeDocument() returns null
- More idiomatic C++ code style

* Improve variable scope per @chennes feedback

- Use if-with-initialization to scope doc and mdi variables
- Variables now only exist where needed instead of leaking into function scope
- More idiomatic C++ code style
This commit is contained in:
George Peden
2025-09-12 11:26:39 -07:00
committed by GitHub
parent 95840a79d3
commit f2803283b8

View File

@@ -747,6 +747,13 @@ private:
tryAutoRecomputeIfNotSolve(sketchgui->getSketchObject());
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Add Sketch B-Spline"));
// Restore keyboard focus after command restart
if (Gui::Document* doc = Gui::Application::Instance->activeDocument()) {
if (Gui::MDIView* mdi = doc->getActiveView()) {
mdi->setFocus();
}
}
// Add the necessary alignment geometries and constraints
for (size_t i = 0; i < geoIds.size(); ++i) {
addGeometry(points[i], geoIds[i], i == 0);