diff --git a/src/GUI/FGPUICompatDialog.cxx b/src/GUI/FGPUICompatDialog.cxx index 08ea9fbea..18236a30c 100644 --- a/src/GUI/FGPUICompatDialog.cxx +++ b/src/GUI/FGPUICompatDialog.cxx @@ -85,7 +85,9 @@ void FGPUICompatDialog::setupGhost(nasal::Hash& compatModule) .member("y", &FGPUICompatDialog::getY) .member("width", &FGPUICompatDialog::width) .member("height", &FGPUICompatDialog::height) - .member("root", f_dialogRootObject); + .member("root", f_dialogRootObject) + .method("close", &FGPUICompatDialog::requestClose); + using NasalDialogPeer = nasal::Ghost>; NasalDialogPeer::init("CompatDialogPeer") @@ -106,6 +108,8 @@ FGPUICompatDialog::FGPUICompatDialog(SGPropertyNode* props) : FGDialog(props), FGPUICompatDialog::~FGPUICompatDialog() { + _peer->callMethod("doClose"); + _props->setIntValue("lastx", getX()); _props->setIntValue("lasty", getY()); // FIXME: save width/height as well? @@ -762,3 +766,9 @@ std::string FGPUICompatDialog::nasalModule() const { return _module; } + +void FGPUICompatDialog::requestClose() +{ + auto gui = globals->get_subsystem(); + gui->closeDialog(_name); +} diff --git a/src/GUI/FGPUICompatDialog.hxx b/src/GUI/FGPUICompatDialog.hxx index 5aa0247db..e32137954 100644 --- a/src/GUI/FGPUICompatDialog.hxx +++ b/src/GUI/FGPUICompatDialog.hxx @@ -119,6 +119,8 @@ private: // Show the dialog. void display(SGPropertyNode* props); + void requestClose(); + #if 0 // Build the dialog or a subobject of it. puObject* makeObject(SGPropertyNode* props, diff --git a/src/GUI/PUICompatObject.cxx b/src/GUI/PUICompatObject.cxx index ae64276eb..c8a7501f9 100644 --- a/src/GUI/PUICompatObject.cxx +++ b/src/GUI/PUICompatObject.cxx @@ -12,6 +12,7 @@ #include // for copyProperties #include +#include #include
#include @@ -153,6 +154,7 @@ void PUICompatObject::init() } SGSharedPtr childObject = createForType(nodeName, childNode); + childObject->_parent = this; _children.push_back(childObject); } @@ -268,7 +270,12 @@ void PUICompatObject::createNasalPeer() void PUICompatObject::activateBindings() { assert(_enabled); + auto guiSub = globals->get_subsystem(); + assert(guiSub); + + guiSub->setActiveDialog(dialog()); fireBindingList(_bindings); + guiSub->setActiveDialog(nullptr); } void PUICompatObject::setGeometry(const SGRectd& g)