dabo Commit
Revision 2419
Date: 2006-11-03 06:40:30 -0800 (Fri, 03 Nov 2006)
Author: paul
Changed:
U branches/stable/dabo/ui/uiwx/dGrid.py
Log:
Applied the following commit to the dabo-stable branch:
------------------------------------------------------------------------
r2148 | paul | 2006-05-11 11:25:30 -0700 (Thu, 11 May 2006) | 5 lines
Removed the handling of the grid cell mouse events, and reimplemented them
using plain mouse events to avoid event duplication.
Resolves tracker issue 0137.
------------------------------------------------------------------------
Diff:
Modified: branches/stable/dabo/ui/uiwx/dGrid.py
===================================================================
--- branches/stable/dabo/ui/uiwx/dGrid.py 2006-11-02 15:41:08 UTC (rev
2418)
+++ branches/stable/dabo/ui/uiwx/dGrid.py 2006-11-03 14:40:30 UTC (rev
2419)
@@ -1508,12 +1508,14 @@
def initEvents(self):
- self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK,
self.__onWxMouseLeftDoubleClick)
+ ## pkm: Don't do the grid_cell mouse events, because we handle
it manually and it
+ ## would result in doubling up the events.
+ #self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK,
self.__onWxGridCellMouseLeftDoubleClick)
+ #self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK,
self.__onWxGridCellMouseLeftClick)
+ #self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK,
self.__onWxGridCellMouseRightClick)
self.Bind(wx.grid.EVT_GRID_ROW_SIZE, self.__onWxGridRowSize)
self.Bind(wx.grid.EVT_GRID_SELECT_CELL,
self.__onWxGridSelectCell)
self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.__onWxGridColSize)
- self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK,
self.__onWxMouseLeftClick)
- self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK,
self.__onWxMouseRightClick)
self.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN,
self.__onWxGridEditorShown)
self.Bind(wx.grid.EVT_GRID_EDITOR_CREATED,
self.__onWxGridEditorCreated)
self.Bind(wx.grid.EVT_GRID_CELL_CHANGE,
self.__onWxGridCellChange)
@@ -3009,36 +3011,54 @@
self.raiseEvent(dEvents.GridHeaderPaint, evt)
evt.Skip()
+ def _getColRowForPosition(self, pos):
+ """Used in the mouse event handlers to stuff the col, row into
EventData."""
+ col = self.XToCol(pos[0])
+ row = self.YToRow(pos[1])
+ if col < 0 or row < 0:
+ # click was outside grid cell area
+ col, row = None, None
+ return col, row
+
+
def __onWxMouseLeftDoubleClick(self, evt):
- self.raiseEvent(dEvents.GridMouseLeftDoubleClick, evt)
+ col, row = self._getColRowForPosition(evt.GetPosition())
+ self.raiseEvent(dEvents.GridMouseLeftDoubleClick, evt, col=col,
row=row)
evt.Skip()
def __onWxMouseLeftClick(self, evt):
- self.raiseEvent(dEvents.GridMouseLeftClick, evt)
+ col, row = self._getColRowForPosition(evt.GetPosition())
+ self.raiseEvent(dEvents.GridMouseLeftClick, evt, col=col,
row=row)
evt.Skip()
def __onWxMouseLeftDown(self, evt):
- self.raiseEvent(dEvents.GridMouseLeftDown, evt)
+ col, row = self._getColRowForPosition(evt.GetPosition())
+ self.raiseEvent(dEvents.GridMouseLeftDown, evt, col=col,
row=row)
evt.Skip()
def __onWxMouseLeftUp(self, evt):
- self.raiseEvent(dEvents.GridMouseLeftUp, evt)
+ col, row = self._getColRowForPosition(evt.GetPosition())
+ self.raiseEvent(dEvents.GridMouseLeftUp, evt, col=col, row=row)
evt.Skip()
def __onWxMouseMotion(self, evt):
- self.raiseEvent(dEvents.GridMouseMove, evt)
+ col, row = self._getColRowForPosition(evt.GetPosition())
+ self.raiseEvent(dEvents.GridMouseMove, evt, col=col, row=row)
evt.Skip()
def __onWxMouseRightClick(self, evt):
- self.raiseEvent(dEvents.GridMouseRightClick, evt)
+ col, row = self._getColRowForPosition(evt.GetPosition())
+ self.raiseEvent(dEvents.GridMouseRightClick, evt, col=col,
row=row)
evt.Skip()
def __onWxMouseRightDown(self, evt):
- self.raiseEvent(dEvents.GridMouseRightDown, evt)
+ col, row = self._getColRowForPosition(evt.GetPosition())
+ self.raiseEvent(dEvents.GridMouseRightDown, evt, col=col,
row=row)
evt.Skip()
def __onWxMouseRightUp(self, evt):
- self.raiseEvent(dEvents.GridMouseRightUp, evt)
+ col, row = self._getColRowForPosition(evt.GetPosition())
+ self.raiseEvent(dEvents.GridMouseRightUp, evt, col=col, row=row)
evt.Skip()
##----------------------------------------------------------##
@@ -3896,8 +3916,8 @@
self.RowLabels = ["a", "b", "3"]
#self.ShowRowLabels = True
+
if __name__ == '__main__':
- class TestForm(dabo.ui.dForm):
def afterInit(self):
self.BackColor = "khaki"
g = self.grid = _dGrid_test(self, RegID="sampleGrid")
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev