From 62be29c64024957ab5ecd58aad041996c13d6890 Mon Sep 17 00:00:00 2001 From: david Date: Sun, 19 Jan 2003 23:04:03 +0000 Subject: [PATCH] Make some allowances for a dialog closing in the middle of a callback. Add support for combo fields. --- src/GUI/dialog.cxx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/GUI/dialog.cxx b/src/GUI/dialog.cxx index 525ffb3ec..2a5bd4c3b 100644 --- a/src/GUI/dialog.cxx +++ b/src/GUI/dialog.cxx @@ -20,8 +20,12 @@ action_callback (puObject * object) GUIInfo * info = (GUIInfo *)object->getUserData(); NewGUI * gui = (NewGUI *)globals->get_subsystem("gui"); gui->setCurrentWidget(info->widget); - for (int i = 0; i < info->bindings.size(); i++) + int nBindings = info->bindings.size(); + for (int i = 0; i < nBindings; i++) { info->bindings[i]->fire(); + if (gui->getCurrentWidget() == 0) + break; + } gui->setCurrentWidget(0); } @@ -226,6 +230,20 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight) b = new puButton(x, y, legend); setupObject(b, props); return b; + } else if (type == "combo") { + vector value_nodes = props->getChildren("value"); + char ** entries = new char*[value_nodes.size()+1]; + for (int i = 0, j = value_nodes.size() - 1; + i < value_nodes.size(); + i++, j--) + entries[i] = (char *)value_nodes[i]->getStringValue(); + entries[value_nodes.size()] = 0; + puComboBox * combo = + new puComboBox(x, y, x + width, y + height, entries, + props->getBoolValue("editable", false)); +// delete entries; + setupObject(combo, props); + return combo; } else { return 0; }