Adding support for selecting user data type for function return type
authorlaurent
Thu, 09 Jun 2011 17:51:53 +0200
changeset 544 ad4dd01c3c35
parent 543 2f660878c2a7
child 545 2f60f3d3c9ad
Adding support for selecting user data type for function return type
VariablePanel.py
--- a/VariablePanel.py	Wed Jun 08 18:44:25 2011 +0200
+++ b/VariablePanel.py	Thu Jun 09 17:51:53 2011 +0200
@@ -583,15 +583,6 @@
         self.ClassFilter.SetStringSelection(_(reverse_transfer[self.Filter]))
         self.RefreshTypeList()
 
-        if element_type == "function":
-            for base_type in self.Controler.GetBaseTypes():
-                self.ReturnType.Append(base_type)
-            self.ReturnType.Enable(True)
-        else:
-            self.ReturnType.Enable(False)
-            self.staticText1.Hide()
-            self.ReturnType.Hide()
-            
         self.VariablesGrid.SetTable(self.Table)
         self.VariablesGrid.SetRowLabelSize(0)
         for col in range(self.Table.GetNumberCols()):
@@ -625,12 +616,25 @@
             returnType = None
             self.Values = self.Controler.GetConfigurationResourceGlobalVars(words[1], words[2])
         else:
+            if self.ElementType == "function":
+                self.ReturnType.Clear()
+                for base_type in self.Controler.GetDataTypes(self.TagName, True):
+                    self.ReturnType.Append(base_type)
+                returnType = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
+            else:
+                returnType = None
             self.PouIsUsed = self.Controler.PouIsUsed(words[1])
-            returnType = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
             self.Values = self.Controler.GetEditedElementInterfaceVars(self.TagName)
         
-        if returnType and self.ReturnType.IsEnabled():
+        if returnType is not None:
             self.ReturnType.SetStringSelection(returnType)
+            self.ReturnType.Enable(True)
+            self.staticText1.Show()
+            self.ReturnType.Show()
+        else:
+            self.ReturnType.Enable(False)
+            self.staticText1.Hide()
+            self.ReturnType.Hide()
         
         self.RefreshValues()
         self.RefreshButtons()