controls/DurationCellEditor.py
changeset 657 b286a16162fc
parent 655 435e2d8ee580
child 663 6ea5c76ea7bc
equal deleted inserted replaced
656:ff38b7250b64 657:b286a16162fc
   127         self.SetControl(self.CellControl)
   127         self.SetControl(self.CellControl)
   128         if evt_handler:
   128         if evt_handler:
   129             self.CellControl.PushEventHandler(evt_handler)
   129             self.CellControl.PushEventHandler(evt_handler)
   130 
   130 
   131     def BeginEdit(self, row, col, grid):
   131     def BeginEdit(self, row, col, grid):
       
   132         self.CellControl.Enable()
   132         self.CellControl.SetValue(self.Table.GetValueByName(row, 'Interval'))
   133         self.CellControl.SetValue(self.Table.GetValueByName(row, 'Interval'))
   133         self.CellControl.SetFocus()
   134         self.CellControl.SetFocus()
   134 
   135 
   135     def EndEdit(self, row, col, grid):
   136     def EndEdit(self, row, col, grid):
   136         duration = self.CellControl.GetValue()
   137         duration = self.CellControl.GetValue()
   137         old_duration = self.Table.GetValueByName(row, 'Interval')
   138         old_duration = self.Table.GetValueByName(row, 'Interval')
   138         if duration != old_duration:
   139         changed = duration != old_duration
       
   140         if changed:
   139             self.Table.SetValueByName(row, 'Interval', duration)
   141             self.Table.SetValueByName(row, 'Interval', duration)
   140             return True
   142         self.CellControl.Disable()
   141         return False
   143         return False
   142 
   144 
   143     def SetSize(self, rect):
   145     def SetSize(self, rect):
   144         self.CellControl.SetDimensions(rect.x + 1, rect.y,
   146         self.CellControl.SetDimensions(rect.x + 1, rect.y,
   145                                         rect.width, rect.height,
   147                                         rect.width, rect.height,