summaryrefslogtreecommitdiff
blob: ab4fc703f507728e1194e2e90d92c5a880723485 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
From e22d1534d486a7b46612ca6f6cd693b8fa4635d2 Mon Sep 17 00:00:00 2001
From: Chris Rowett <rowett@yahoo.com>
Date: Tue, 10 Jul 2018 23:22:20 +0100
Subject: [PATCH] bugfix: do not process other mouse buttons until current
 button released

---
 gui-wx/wxview.cpp | 15 +++++++++++++++
 gui-wx/wxview.h   |  2 ++
 2 files changed, 17 insertions(+)

--- a/gui-wx/wxview.cpp
+++ b/gui-wx/wxview.cpp
@@ -2801,6 +2801,13 @@ void PatternView::OnMouseDown(wxMouseEvent& event)
     int button = event.GetButton();
     int modifiers = GetMouseModifiers(event);
     
+    // ignore if a mouse button is already down
+    if (mouseisdown) return;
+
+    // flag that a mouse button is down
+    mouseisdown = true;
+    whichbuttondown = button;
+
     if (waitingforclick && button == wxMOUSE_BTN_LEFT) {
         // save paste location
         pastex = x;
@@ -2870,6 +2877,13 @@ void PatternView::OnMouseDown(wxMouseEvent& event)
 
 void PatternView::OnMouseUp(wxMouseEvent& event)
 {
+    // if the button released was not the first held down then ignore
+    int button = event.GetButton();
+    if (button != whichbuttondown) return;
+
+    // same button released so process
+    mouseisdown = false;
+
     if (drawingcells || selectingcells || movingview || clickedcontrol > NO_CONTROL) {
         StopDraggingMouse();
     } else if (mainptr->draw_pending) {
@@ -3273,6 +3287,7 @@ PatternView::PatternView(wxWindow* parent, wxCoord x, wxCoord y, int wd, int ht,
     selectingcells = false;    // not selecting cells
     movingview = false;        // not moving view
     waitingforclick = false;   // not waiting for user to click
+    mouseisdown = false;       // mouse button is not down
     nopattupdate = false;      // enable pattern updates
     showcontrols = false;      // not showing translucent controls
     oldcursor = NULL;          // for toggling cursor via shift key
--- a/gui-wx/wxview.h
+++ b/gui-wx/wxview.h
@@ -102,6 +102,8 @@ public:
     bool movingview;              // moving view due to dragging mouse?
     bool nopattupdate;            // disable pattern updates?
     bool showcontrols;            // draw translucent controls?
+    bool mouseisdown;             // mouse button held down?
+    int whichbuttondown;          // which mouse button is down
     wxRect controlsrect;          // location of translucent controls
     wxRect pasterect;             // area to be pasted
     wxCursor* oldcursor;          // non-NULL if shift key has toggled cursor
-- 
2.19.2