From 1804fe9b51c902003511022872a64ef4bc7775fc Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 6 Jul 2015 18:05:36 +0300 Subject: [PATCH] Issue #720:Set cursor at the same position at editing of text in spin box --- src/ModuleBase/ModuleBase_Tools.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 2deb05c7c..d62879f7f 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -113,9 +113,13 @@ QPixmap lighter(const QString& theIcon, const int theLighterValue) void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText) { - bool isBlocked = theSpin->blockSignals(true); - theSpin->setText(theText); - theSpin->blockSignals(isBlocked); + if (theSpin->text() != theText) { + // In order to avoid extra text setting because it will + // reset cursor position in control + bool isBlocked = theSpin->blockSignals(true); + theSpin->setText(theText); + theSpin->blockSignals(isBlocked); + } } void setSpinValue(QDoubleSpinBox* theSpin, double theValue) -- 2.39.2