Set cursor to the first widget in the property panel.
For line creation signal is emitted during start, but, the property panel is built after the operation is stopped and this information do not go to the first point control.
virtual bool restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
- /// Set focus to the current widget if it corresponds to the given attribute
+ /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
/// \param theAttribute name
- virtual bool focusTo(const std::string& theAttributeName) = 0;
+ virtual bool canFocusTo(const std::string& theAttributeName) = 0;
+
+ /// Set focus to the current widget if it corresponds to the given attribute
+ virtual void focusTo() = 0;
/// Returns list of widget controls
/// \return a control list
return true;
}
-bool ModuleBase_WidgetPoint2D::focusTo(const std::string& theAttributeName)
+bool ModuleBase_WidgetPoint2D::canFocusTo(const std::string& theAttributeName)
{
- if (theAttributeName != myFeatureAttributeID)
- return false;
+ return theAttributeName == myFeatureAttributeID;
+}
- if (!myXSpin->hasFocus() && !myYSpin->hasFocus()) {
+void ModuleBase_WidgetPoint2D::focusTo()
+{
+ if (!myXSpin->hasFocus() && !myYSpin->hasFocus())
myXSpin->setFocus();
- }
-
- return true;
}
QWidget* ModuleBase_WidgetPoint2D::getControl() const
virtual bool restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature);
- /// Set focus to the current widget if it corresponds to the given attribute
+ /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
/// \param theAttribute name
- virtual bool focusTo(const std::string& theAttributeName);
+ virtual bool canFocusTo(const std::string& theAttributeName);
+
+ /// Set focus to the current widget if it corresponds to the given attribute
+ virtual void focusTo();
/// Returns the internal parent wiget control, that can be shown anywhere
/// \returns the widget
myWidgets = theWidgets;
if (!theWidgets.empty()) {
-
QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end();
for (; anIt != aLast; anIt++) {
connect(*anIt, SIGNAL(keyReleased(const std::string&, QKeyEvent*)),
setTabOrder(anOkBtn, aCancelBtn);
}
}
+ ModuleBase_ModelWidget* aWidget = theWidgets.first();
+ if (aWidget)
+ aWidget->focusTo();
}
}
}
else {
foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
- if (eachWidget->focusTo(theAttributeName))
+ if (eachWidget->canFocusTo(theAttributeName)) {
+ eachWidget->focusTo();
break;
+ }
}
}
}