]> git.mxchange.org Git - flightgear.git/commitdiff
Make some allowances for a dialog closing in the middle of a callback.
authordavid <david>
Sun, 19 Jan 2003 23:04:03 +0000 (23:04 +0000)
committerdavid <david>
Sun, 19 Jan 2003 23:04:03 +0000 (23:04 +0000)
Add support for combo fields.

src/GUI/dialog.cxx

index 525ffb3ec87e6ecade8e4b2636f0e5d292890663..2a5bd4c3b66d556f3f92d35712651a30b40a1edd 100644 (file)
@@ -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<SGPropertyNode_ptr> 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;
     }