Skip to content

Commit

Permalink
Only Bind on_motion while left button down.
Browse files Browse the repository at this point in the history
Fixes #141
  • Loading branch information
itsayellow committed Sep 17, 2018
1 parent e287300 commit 72db396
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 7 additions & 3 deletions marcam/image_scrolled_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ def __init__(self, parent, *args, **kwargs):
self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down)
self.Bind(wx.EVT_LEFT_UP, self.on_left_up)
self.Bind(wx.EVT_RIGHT_DOWN, self.on_right_down)
self.Bind(wx.EVT_MOTION, self.on_motion)

# determine widths of scrollbars
self.get_scrollbar_widths()
Expand Down Expand Up @@ -665,6 +664,9 @@ def on_left_down(self, evt):

# we allow click outside of image in case we drag onto image

# start following motion until on_left_up, in case this is a drag
self.Bind(wx.EVT_MOTION, self.on_motion)

# in case we need a drag capture mouse
self.CaptureMouse()

Expand All @@ -682,8 +684,7 @@ def on_left_down(self, evt):
'is_toggling':is_toggling,
}

# don't debug on_motion normally, too much log msgs
#@debug_fxn
@debug_fxn_debug
def on_motion(self, evt):
"""EVT_MOTION handler: "mouse moving". Used esp. to track dragging
Expand Down Expand Up @@ -788,6 +789,9 @@ def on_left_up(self, evt):
if self.HasCapture():
self.ReleaseMouse()

# stop following motion
self.Unbind(wx.EVT_MOTION)

@debug_fxn
def on_right_down(self, evt):
"""EVT_RIGHT_DOWN handler: mouse right-clicks
Expand Down
9 changes: 7 additions & 2 deletions marcam/image_scrolled_canvas_marks.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ def on_left_down(self, evt):
else:
# we allow click outside of image in case we drag onto image

# start following motion until on_left_up, in case this is a drag
self.Bind(wx.EVT_MOTION, self.on_motion)

# in case we need a drag capture mouse
self.CaptureMouse()

Expand Down Expand Up @@ -181,8 +184,7 @@ def on_left_down(self, evt):
'mark_pt_is_sel':mark_pt_is_sel
}

# don't debug on_motion normally, too much log msgs
#@debug_fxn
@debug_fxn_debug
def on_motion(self, evt):
"""EVT_MOTION handler: "mouse moving". Used esp. to track dragging
Expand Down Expand Up @@ -407,6 +409,9 @@ def on_left_up(self, evt):
if self.HasCapture():
self.ReleaseMouse()

# stop following motion
self.Unbind(wx.EVT_MOTION)

@debug_fxn
def move_mark(self, from_mark_pt, to_mark_pt, is_selected):
"""Move mark from one location to another
Expand Down

0 comments on commit 72db396

Please sign in to comment.