From cc21f7540560d85b60431cf8d820d93c5e66800a Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 9 Nov 2015 12:40:07 +0300 Subject: [PATCH] When automatically switching in edit mode (OK button enabled), the value of the active input should be automatically selected --- src/ModuleBase/ModuleBase_ModelWidget.h | 3 +++ src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp | 5 +++++ src/ModuleBase/ModuleBase_WidgetDoubleValue.h | 3 +++ src/PartSet/PartSet_SketcherReetntrantMgr.cpp | 4 +++- src/PartSet/PartSet_WidgetPoint2d.cpp | 5 +++++ src/PartSet/PartSet_WidgetPoint2d.h | 3 +++ 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index dd2c9edd3..6e6b1aac4 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -107,6 +107,9 @@ Q_OBJECT /// \return the state whether the widget can accept the focus virtual bool focusTo(); + /// Select the internal content if it can be selected. It is empty in the default realization + virtual void selectContent() {} + /// The method called when widget is activated void activate(); diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 4e6ce242c..a43f02cb6 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -144,6 +144,11 @@ bool ModuleBase_WidgetDoubleValue::restoreValueCustom() return true; } +void ModuleBase_WidgetDoubleValue::selectContent() +{ + mySpinBox->selectAll(); +} + QList ModuleBase_WidgetDoubleValue::getControls() const { QList aList; diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h index 8c1e0a1d8..cfd49221c 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h @@ -37,6 +37,9 @@ Q_OBJECT virtual ~ModuleBase_WidgetDoubleValue(); + /// Select the internal content if it can be selected. It is empty in the default realization + virtual void selectContent(); + /// Returns list of widget controls /// \return a control list virtual QList getControls() const; diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 113078af8..852391336 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -297,8 +297,10 @@ bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev aPreviousAttributeWidget = aWidgets[i]; } // If the current widget is a selector, do nothing, it processes the mouse press - if (aPreviousAttributeWidget && !aPreviousAttributeWidget->isViewerSelector()) + if (aPreviousAttributeWidget && !aPreviousAttributeWidget->isViewerSelector()) { aPreviousAttributeWidget->focusTo(); + aPreviousAttributeWidget->selectContent(); + } } } } diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 020a9be68..97c5b1c4e 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -167,6 +167,11 @@ bool PartSet_WidgetPoint2D::setSelection(QList& theValues, return isDone; } +void PartSet_WidgetPoint2D::selectContent() +{ + myXSpin->selectAll(); +} + bool PartSet_WidgetPoint2D::setPoint(double theX, double theY) { if (fabs(theX) >= MaxCoordinate) diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index aac5640c0..e5e540f57 100755 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -56,6 +56,9 @@ Q_OBJECT virtual bool setSelection(QList& theValues, const bool theToValidate); + /// Select the internal content if it can be selected. It is empty in the default realization + virtual void selectContent(); + /// Returns list of widget controls /// \return a control list virtual QList getControls() const; -- 2.39.2