Bug on enumerated datatype values editor fixed
authorlbessard
Tue, 22 Jan 2008 10:53:34 +0100
changeset 150 f7832baaad84
parent 149 189ebdde3eb9
child 151 aaa80b48bead
Bug on enumerated datatype values editor fixed
DataTypeEditor.py
--- a/DataTypeEditor.py	Wed Jan 16 09:52:37 2008 +0100
+++ b/DataTypeEditor.py	Tue Jan 22 10:53:34 2008 +0100
@@ -316,15 +316,20 @@
     
     def OnEnumeratedValueEndEdit(self, event):
         text = event.GetText()
-        if text.upper() in [string.upper() for string in self.EnumeratedValues.GetStrings()]:
-            message = wx.MessageDialog(self, "\"%s\" value already defined!"%text, "Error", wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
-            event.Veto()
-        elif text.upper() in IEC_KEYWORDS:
-            message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%text, "Error", wx.OK|wx.ICON_ERROR)
-            message.ShowModal()
-            message.Destroy()
+        if self.EnumeratedValues.GetStrings()[event.GetIndex()].upper() != text.upper():
+            if text.upper() in [string.upper() for string in self.EnumeratedValues.GetStrings()]:
+                message = wx.MessageDialog(self, "\"%s\" value already defined!"%text, "Error", wx.OK|wx.ICON_ERROR)
+                message.ShowModal()
+                message.Destroy()
+                event.Veto()
+            elif text.upper() in IEC_KEYWORDS:
+                message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%text, "Error", wx.OK|wx.ICON_ERROR)
+                message.ShowModal()
+                message.Destroy()
+            else:
+                wx.CallAfter(self.RefreshEnumeratedValues)
+                wx.CallAfter(self.RefreshTypeInfos)
+                event.Skip()
         else:
             wx.CallAfter(self.RefreshEnumeratedValues)
             wx.CallAfter(self.RefreshTypeInfos)