- ModuleBase_Tools::zeroMargins(aLay);
-
- QLineEdit* aEditor = new QLineEdit(QString::number(theValue), &aDlg);
- aEditor->setValidator(new QDoubleValidator(aEditor));
- QObject::connect(aEditor, SIGNAL(returnPressed()), &aDlg, SLOT(accept()));
- aLay->addWidget(aEditor);
-
- QPoint aPoint = QCursor::pos();
- aDlg.move(aPoint);
-
- isDone = aDlg.exec() == QDialog::Accepted;
- double aValue = theValue;
- if (isDone)
- aValue = aEditor->text().toDouble();
- return aValue;
+ aLay->setContentsMargins(2, 2, 2, 2);
+
+ ModuleBase_ParamSpinBox* anEditor = new ModuleBase_ParamSpinBox(&aDlg);
+ anEditor->enableKeyPressEvent(true);
+
+ anEditor->setMinimum(0);
+ anEditor->setMaximum(DBL_MAX);
+ if (outText.isEmpty())
+ anEditor->setValue(outValue);
+ else
+ anEditor->setText(outText);
+
+ aLay->addWidget(anEditor);
+
+ anEditor->setFocus();
+ anEditor->selectAll();
+ QObject::connect(anEditor, SIGNAL(editingFinished()), &aDlg, SLOT(accept()));
+
+ aDlg.move(QCursor::pos());
+ aDlg.exec();
+ outText = anEditor->text();
+ bool isDouble;
+ double aValue = outText.toDouble(&isDouble);
+ if (isDouble) {
+ outValue = aValue;
+ outText = ""; // return empty string, if it's can be converted to a double
+ }