add threshold for button dragging in case of jittery mouse

master
Keegi 2011-10-27 16:36:30 +03:00
parent d2db9ca389
commit 010a3fcb15
1 changed files with 10 additions and 0 deletions

View File

@ -866,6 +866,15 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
elif e.Dragging() and e.ButtonIsDown(wx.MOUSE_BTN_LEFT):
obj = e.GetEventObject()
scrpos = obj.ClientToScreen(e.GetPosition())
if not hasattr(self,"dragpos"):
self.dragpos = scrpos
e.Skip()
return
else:
dx,dy=self.dragpos[0]-scrpos[0],self.dragpos[1]-scrpos[1]
if dx*dx+dy*dy < 5*5: # threshold to detect dragging for jittery mice
e.Skip()
return
if not hasattr(self,"dragging"):
# init dragging of the custom button
if hasattr(obj,"custombutton"):
@ -945,6 +954,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
del self.dragging
wx.CallAfter(self.cbuttons_reload)
del self.last_drag_dest
del self.dragpos
else:
e.Skip()