From a6a7303e253e757d4cc0da304c33bbe6539261a1 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 9 Oct 2019 13:39:24 +0200 Subject: [PATCH] Fixed context menu showing up when user right clicks on 3D scene and release the mouse button after dragging over the objects list --- src/slic3r/GUI/GLCanvas3D.cpp | 27 ++++++++++++++------------- src/slic3r/GUI/GLCanvas3D.hpp | 2 ++ src/slic3r/GUI/GUI_ObjectList.cpp | 8 +++++++- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index dd80b9948..c55d64b47 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2662,19 +2662,6 @@ std::string format_mouse_event_debug_message(const wxMouseEvent &evt) void GLCanvas3D::on_mouse(wxMouseEvent& evt) { - auto mouse_up_cleanup = [this](){ - m_moving = false; - m_mouse.drag.move_volume_idx = -1; - m_mouse.set_start_position_3D_as_invalid(); - m_mouse.set_start_position_2D_as_invalid(); - m_mouse.dragging = false; - m_mouse.ignore_left_up = false; - m_dirty = true; - - if (m_canvas->HasCapture()) - m_canvas->ReleaseMouse(); - }; - #if ENABLE_RETINA_GL const float scale = m_retina_helper->get_scale_factor(); evt.SetX(evt.GetX() * scale); @@ -3511,6 +3498,20 @@ void GLCanvas3D::export_toolpaths_to_obj(const char* filename) const m_volumes.export_toolpaths_to_obj(filename); } +void GLCanvas3D::mouse_up_cleanup() +{ + m_moving = false; + m_mouse.drag.move_volume_idx = -1; + m_mouse.set_start_position_3D_as_invalid(); + m_mouse.set_start_position_2D_as_invalid(); + m_mouse.dragging = false; + m_mouse.ignore_left_up = false; + m_dirty = true; + + if (m_canvas->HasCapture()) + m_canvas->ReleaseMouse(); +} + bool GLCanvas3D::_is_shown_on_screen() const { return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false; diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index fb767360c..2c2676ae7 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -624,6 +624,8 @@ public: bool has_toolpaths_to_export() const; void export_toolpaths_to_obj(const char* filename) const; + void mouse_up_cleanup(); + private: bool _is_shown_on_screen() const; diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 879ebc752..a5317b8a6 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -778,7 +778,13 @@ void ObjectList::OnChar(wxKeyEvent& event) void ObjectList::OnContextMenu(wxDataViewEvent&) { - list_manipulation(true); + // Do not show the context menu if the user pressed the right mouse button on the 3D scene and released it on the objects list + GLCanvas3D* canvas = wxGetApp().plater()->canvas3D(); + bool evt_context_menu = (canvas != nullptr) ? !canvas->is_mouse_dragging() : true; + if (!evt_context_menu) + canvas->mouse_up_cleanup(); + + list_manipulation(evt_context_menu); } void ObjectList::list_manipulation(bool evt_context_menu/* = false*/)