diff --git a/src/Gui/ViewProviderPythonFeature.cpp b/src/Gui/ViewProviderPythonFeature.cpp index af668ed6a..cde1d8e19 100644 --- a/src/Gui/ViewProviderPythonFeature.cpp +++ b/src/Gui/ViewProviderPythonFeature.cpp @@ -383,6 +383,41 @@ bool ViewProviderPythonFeatureImp::unsetEdit(int ModNum) return false; } +bool ViewProviderPythonFeatureImp::doubleClicked(void) +{ + // Run the onChanged method of the proxy object. + Base::PyGILStateLocker lock; + try { + App::Property* proxy = object->getPropertyByName("Proxy"); + if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) { + Py::Object vp = static_cast(proxy)->getValue(); + if (vp.hasAttr(std::string("doubleClicked"))) { + if (vp.hasAttr("__object__")) { + Py::Callable method(vp.getAttr(std::string("doubleClicked"))); + Py::Tuple args; + //args.setItem(0, Py::Int(ModNum)); + Py::Boolean ok(method.apply(args)); + return (bool)ok; + } + else { + Py::Callable method(vp.getAttr(std::string("doubleClicked"))); + Py::Tuple args(1); + args.setItem(0, Py::Object(object->getPyObject(), true)); + Py::Boolean ok(method.apply(args)); + return (bool)ok; + } + } + } + } + catch (Py::Exception&) { + Base::PyException e; // extract the Python error text + e.ReportException(); + } + + return false; +} + + void ViewProviderPythonFeatureImp::attach(App::DocumentObject *pcObject) { // Run the attach method of the proxy object. diff --git a/src/Gui/ViewProviderPythonFeature.h b/src/Gui/ViewProviderPythonFeature.h index 0af989cc8..ff3e34cff 100644 --- a/src/Gui/ViewProviderPythonFeature.h +++ b/src/Gui/ViewProviderPythonFeature.h @@ -52,6 +52,7 @@ public: std::vector getSelectionShape(const char* Element) const; bool setEdit(int ModNum); bool unsetEdit(int ModNum); + bool doubleClicked(void); /** @name Update data methods*/ //@{ @@ -308,6 +309,15 @@ protected: if (!ok) ViewProviderT::unsetEdit(ModNum); } + virtual bool doubleClicked(void) + { + bool ok = imp->doubleClicked(); + if (!ok) + return ViewProviderT::doubleClicked(); + else + return true; + } + private: ViewProviderPythonFeatureImp* imp; App::DynamicProperty *props;