Dirksen Lau wrote:
I'm trying the water of the world of wxPython. The sample GridDraggable looks helpful in my case. When I re-arrange the order of the rows by dragging, I'm very pleased to see that the grid will scroll automatically if my cursor hovers at the top or the bottom of the grid while dragging. The problem is it happens too fast, very often it just jumps right to the top or the bottom. It is very difficult to drop the row in the middle. So how do I slow it down? Please help!
Please try this patch.
Index: wxPython/wx/lib/gridmovers.py
···
===================================================================
RCS file: /pack/cvsroots/wxwidgets/wxWidgets/wxPython/wx/lib/gridmovers.py,v
retrieving revision 1.10
diff -u -4 -r1.10 gridmovers.py
--- wxPython/wx/lib/gridmovers.py 2004/10/15 00:51:57 1.10
+++ wxPython/wx/lib/gridmovers.py 2005/06/01 23:38:55
@@ -251,9 +251,11 @@
self.Bind(wx.EVT_LEFT_UP, self.OnRelease)
def OnMouseMove(self,evt):
if self.isDragging:
- if abs(self.startX - evt.m_x) >= 3:
+ if abs(self.startX - evt.m_x) >= 3 \
+ and abs(evt.m_x - self.lastX) >= 3:
+ self.lastX = evt.m_x
self.didMove = True
sx,y = self.grid.GetViewStart()
w,h = self.lwin.GetClientSize()
x = sx * self.ux
@@ -287,12 +289,11 @@
self.colWin.DisplayAt(px,y)
return
- evt.Skip()
def OnPress(self,evt):
- self.startX = evt.m_x
+ self.startX = self.lastX = evt.m_x
sx = self.grid.GetViewStart()[0] * self.ux
sx -= self.grid._rlSize
px,py = self.lwin.ClientToScreenXY(evt.m_x,evt.m_y)
px,py = self.grid.ScreenToClientXY(px,py)
@@ -372,9 +373,11 @@
self.Bind(wx.EVT_LEFT_UP, self.OnRelease)
def OnMouseMove(self,evt):
if self.isDragging:
- if abs(self.startY - evt.m_y) >= 3:
+ if abs(self.startY - evt.m_y) >= 3 \
+ and abs(evt.m_y - self.lastY) >= 3:
+ self.lastY = evt.m_y
self.didMove = True
x,sy = self.grid.GetViewStart()
w,h = self.lwin.GetClientSizeTuple()
y = sy * self.uy
@@ -411,12 +414,11 @@
self.rowWin.DisplayAt(x,py)
return
- evt.Skip()
def OnPress(self,evt):
- self.startY = evt.m_y
+ self.startY = self.lastY = evt.m_y
sy = self.grid.GetViewStart()[1] * self.uy
sy -= self.grid._clSize
px,py = self.lwin.ClientToScreenXY(evt.m_x,evt.m_y)
px,py = self.grid.ScreenToClientXY(px,py)
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!