add double click handling to the PythonViewProvider template
This commit is contained in:
parent
bd196395db
commit
1b7acb839b
|
@ -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<App::PropertyPythonObject*>(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.
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
std::vector<Base::Vector3d> 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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user