From 42c5d624cb70c4493ee3f225458f2d6cd9e60b32 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 20 Mar 2019 15:30:03 +0100 Subject: [PATCH] Fix into GLToolbar::on_mouse() --- src/slic3r/GUI/GLToolbar.cpp | 24 ++++++++++++++++++++---- src/slic3r/GUI/GLToolbar.hpp | 2 ++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index 5ac5bf92f5..ac79784adf 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -157,7 +157,7 @@ GLToolbar::GLToolbar(GLToolbar::EType type) #if ENABLE_SVG_ICONS , m_icons_texture_dirty(true) #endif // ENABLE_SVG_ICONS - , m_mouse_capture({false, false, false}) + , m_mouse_capture({ false, false, false, nullptr }) , m_tooltip("") { } @@ -418,8 +418,17 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent) m_mouse_capture.middle = false; else if (evt.RightUp()) m_mouse_capture.right = false; - else if (m_mouse_capture.any() && evt.Dragging()) - processed = true; + else if (m_mouse_capture.any()) + { + if (evt.Dragging()) + processed = true; + else if (evt.Entering() && (m_mouse_capture.parent == &parent)) + // Resets the mouse capture state to avoid setting the dragging event as processed when, for example, + // the item action opens a modal dialog + // Keeps the mouse capture state if the entering event happens on different parent from the one + // who received the button down event, to prevent, for example, dragging when switching between scene views + m_mouse_capture.reset(); + } int item_id = contains_mouse(mouse_pos, parent); if (item_id == -1) @@ -429,10 +438,11 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent) } else { - // mouse inside toolbar only + // mouse inside toolbar if (evt.LeftDown() || evt.LeftDClick()) { m_mouse_capture.left = true; + m_mouse_capture.parent = &parent; if ((item_id != -2) && !m_items[item_id]->is_separator()) { // mouse is inside an icon @@ -441,9 +451,15 @@ bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent) } } else if (evt.MiddleDown()) + { m_mouse_capture.middle = true; + m_mouse_capture.parent = &parent; + } else if (evt.RightDown()) + { m_mouse_capture.right = true; + m_mouse_capture.parent = &parent; + } else if (evt.LeftUp()) processed = true; } diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index 07d1fcb92f..95953795f0 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -236,8 +236,10 @@ private: bool left; bool middle; bool right; + GLCanvas3D* parent; bool any() const { return left || middle || right; } + void reset() { left = middle = right = false; parent = nullptr; } }; MouseCapture m_mouse_capture;