From 010a3fcb1585cd97c6af4d34b0b207e243d30c36 Mon Sep 17 00:00:00 2001 From: Keegi Date: Thu, 27 Oct 2011 16:36:30 +0300 Subject: [PATCH] add threshold for button dragging in case of jittery mouse --- pronterface.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pronterface.py b/pronterface.py index 2adbf6c..e74b41c 100755 --- a/pronterface.py +++ b/pronterface.py @@ -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()