#include <QMouseEvent>
-#define APPLY_BY_ENTER_OR_TAB
-
PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent,
ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData,
: ModuleBase_WidgetDoubleValue(theParent, theData, theParentId), myWorkshop(theWorkshop)
{
myFirstPntName = theData->getProperty("first_point");
-
- // Reconnect to local slot
-#ifdef APPLY_BY_ENTER_OR_TAB
- // Apply widget value change by enter/tab event.
- //disconnect(mySpinBox, SIGNAL(editingFinished()), this, SIGNAL(valuesChanged()));
- disconnect(mySpinBox, SIGNAL(valueStored()), this, SIGNAL(valuesChanged()));
- connect(mySpinBox, SIGNAL(editingFinished()), this, SLOT(onValuesChanged()));
- connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesModified()));
-#else
- disconnect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
- connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
-#endif
}
PartSet_WidgetPoint2dDistance::~PartSet_WidgetPoint2dDistance()
std::shared_ptr<GeomAPI_Pnt2d> aPnt = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
setPoint(feature(), aPnt);
- emit focusOutWidget(this);
+
+ // if the validator of the control returns false, focus should not be switched
+ if (getError().isEmpty())
+ emit focusOutWidget(this);
}
void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
setValueState(ModifiedInViewer);
}
-void PartSet_WidgetPoint2dDistance::onValuesChanged()
-{
- emit valuesChanged();
-}
-
bool PartSet_WidgetPoint2dDistance::processEnter()
{
- bool isModified = mySpinBox->isModified();
+ bool isModified = getValueState() == ModifiedInPP;
if (isModified) {
emit valuesChanged();
- mySpinBox->clearModified();
mySpinBox->selectAll();
}
return isModified;