Fix bug when grid is reset and a CellEditor is still active
authorlaurent
Sat, 31 Mar 2012 13:14:53 +0200
changeset 662 3c4e0d4f7a61
parent 661 7891872e6fd7
child 663 6ea5c76ea7bc
Fix bug when grid is reset and a CellEditor is still active
controls/CustomGrid.py
controls/CustomTable.py
--- a/controls/CustomGrid.py	Tue Mar 27 23:59:35 2012 +0200
+++ b/controls/CustomGrid.py	Sat Mar 31 13:14:53 2012 +0200
@@ -84,7 +84,9 @@
             self.DownButton.Enable(self.Editable and 0 <= row < rows - 1)
     
     def CloseEditControl(self):
-        self.SetGridCursor(self.GetGridCursorRow(), self.GetGridCursorCol())
+        row, col = self.GetGridCursorRow(), self.GetGridCursorCol()
+        if row != -1 and col != -1:
+            self.SetGridCursor(row, col)
 
     def AddRow(self):
         self.CloseEditControl()
--- a/controls/CustomTable.py	Tue Mar 27 23:59:35 2012 +0200
+++ b/controls/CustomTable.py	Sat Mar 31 13:14:53 2012 +0200
@@ -69,6 +69,7 @@
         (wx.grid.Grid) -> Reset the grid view.   Call this to
         update the grid if rows and columns have been added or deleted
         """
+        grid.CloseEditControl()
         grid.BeginBatch()
         for current, new, delmsg, addmsg in [
             (self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED),