PLCOpenEditor.py
changeset 97 28337cd092fd
parent 95 ee66a9a1748b
child 98 ec5d7af033d8
--- a/PLCOpenEditor.py	Wed Sep 19 13:28:04 2007 +0200
+++ b/PLCOpenEditor.py	Wed Sep 19 13:32:24 2007 +0200
@@ -794,12 +794,13 @@
             self.Controler.RefreshCurrentElementEditing(selected)
             found = False
             name = self.TabsOpened.GetPageText(selected)
-            root = self.ProjectTree.GetRootItem()
-            item, root_cookie = self.ProjectTree.GetFirstChild(root)
-            while item.IsOk() and not found:
-                if self.ProjectTree.GetItemText(item) == name:
-                    self.ProjectTree.SelectItem(item)
-                item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
+            if self.ProjectTree:
+                root = self.ProjectTree.GetRootItem()
+                item, root_cookie = self.ProjectTree.GetFirstChild(root)
+                while item.IsOk() and not found:
+                    if self.ProjectTree.GetItemText(item) == name:
+                        self.ProjectTree.SelectItem(item)
+                    item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie)
             self.TabsOpened.GetPage(selected).RefreshView()
             self.RefreshFileMenu()
             self.RefreshEditMenu()
@@ -2198,7 +2199,7 @@
     
     def OnDropText(self, x, y, data):
         col = self.ParentWindow.VariablesGrid.XToCol(x)
-        row = self.ParentWindow.VariablesGrid.YToRow(y)
+        row = self.ParentWindow.VariablesGrid.YToRow(y - self.ParentWindow.VariablesGrid.GetColLabelSize())
         if col != wx.NOT_FOUND and row != wx.NOT_FOUND:
             if self.ParentWindow.Table.GetColLabelValue(col) != "Location":
                 return
@@ -2216,7 +2217,7 @@
                         location = "%Q" + values[0]
                     else:
                         location = "%M" + values[0]
-                    self.ParentWindow.Table.SetValue(row - 1, col, location)
+                    self.ParentWindow.Table.SetValue(row, col, location)
                     self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid)
                     self.ParentWindow.SaveValues()
                 dialog.Destroy()