void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent *theEvent)
{
+ bool isEmitKeyRelease = false;
switch (theEvent->key()) {
case Qt::Key_Enter:
case Qt::Key_Return: {
// do not react to the Enter key, the property panel processes it
if (!myIsEmitKeyPressEvent)
return;
+ else
+ isEmitKeyRelease = true;
}
break;
default:
break;
}
QDoubleSpinBox::keyPressEvent(theEvent);
+
+ if (isEmitKeyRelease)
+ emit keyReleased(theEvent);
}
/*!
/// \return the previous value
bool enableKeyPressEvent(const bool& theEnable);
+signals:
+ /// The signal about key release on the control, that corresponds to the attribute
+ /// \param theEvent key release event
+ void keyReleased(QKeyEvent* theEvent);
+
protected slots:
/// Called on text changed
virtual void onTextChanged(const QString&);
ModuleBase_ParamSpinBox* anEditor = new ModuleBase_ParamSpinBox(&aDlg);
anEditor->enableKeyPressEvent(true);
+ if (!myIsEditing) {
+ connect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
+ }
anEditor->setMinimum(0);
anEditor->setMaximum(DBL_MAX);
aDlg.move(QCursor::pos());
aDlg.exec();
+
+ if (!myIsEditing) {
+ disconnect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
+ }
+
outText = anEditor->text();
bool isDouble;
double aValue = outText.toDouble(&isDouble);