]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/dialog.cxx
Fix bug 191, uninitialised HUD color.
[flightgear.git] / src / GUI / dialog.cxx
index fbf758b2979e9ed9f6f94775b7e9b6074094fa24..71852fbc7bdb2007daf500dfc72cac8680f50169 100644 (file)
@@ -1339,8 +1339,41 @@ fgList::update()
 
 void fgComboBox::update()
 {
+  if (_inHit) {
+    return;
+  }
+  
+  std::string curValue(getStringValue());
   fgValueList::update();
   newList(_list);
+  int currentItem = puaComboBox::getCurrentItem();
+
+  
+// look for the previous value, in the new list
+  for (int i = 0; _list[i] != 0; i++) {
+    if (_list[i] == curValue) {
+    // don't set the current item again; this is important to avoid
+    // recursion here if the combo callback ultimately causes another dialog-update
+      if (i != currentItem) {
+        puaComboBox::setCurrentItem(i);
+      }
+      
+      return;
+    }
+  } // of list values iteration
+  
+// cound't find current item, default to first
+  if (currentItem != 0) {
+    puaComboBox::setCurrentItem(0);
+  }
+}
+
+int fgComboBox::checkHit(int b, int up, int x, int y)
+{
+  _inHit = true;
+  int r = puaComboBox::checkHit(b, up, x, y);
+  _inHit = false;
+  return r;
 }
 
 // end of dialog.cxx