DrawSketchController: Fix crazy focus behavior in tool widget (see in the translate tool).

This commit is contained in:
PaddleStroke
2024-02-27 15:30:53 +01:00
parent 1bc62cf113
commit 4ced18c419
3 changed files with 17 additions and 8 deletions

View File

@@ -520,7 +520,7 @@ protected:
virtual void afterEnforceControlParameters()
{
// Give focus to current on-view parameter. In case user interacted outside of 3dview.
if (parameterWithFocus >= 0) {
if (focusAutoPassing && parameterWithFocus >= 0) {
setFocusToOnViewParameter(parameterWithFocus);
}
}
@@ -736,6 +736,8 @@ protected:
return keymanager.get();
}
bool focusAutoPassing = true;
private:
/** @name helper functions */
//@{

View File

@@ -147,7 +147,13 @@ public:
{
adaptDrawingToParameterChange(parameterindex, value); // specialisation interface
// we block the auto passing of focus back to OVP that would occur in mouseMove
// triggered in finishControlsChanged
ControllerBase::focusAutoPassing = false;
ControllerBase::finishControlsChanged();
ControllerBase::focusAutoPassing = true;
}
void parameterFocusOut(int parameterindex)

View File

@@ -157,13 +157,14 @@ bool SketcherToolDefaultWidget::eventFilter(QObject* object, QEvent* event)
}
}
}
else if (event->type() == QEvent::FocusOut) {
for (int i = 0; i < nParameters; i++) {
auto parameterSpinBox = getParameterSpinBox(i);
if (object == parameterSpinBox) {
signalParameterFocusOut(i);
break;
else if (event->type() == QEvent::KeyPress) {
QKeyEvent* ke = static_cast<QKeyEvent*>(event);
if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Return) {
for (int i = 0; i < nParameters; i++) {
if (object == getParameterSpinBox(i)) {
signalParameterFocusOut(i);
return true;
}
}
}
}