diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index ee3c5788f..f8704f3ab 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2310,18 +2310,22 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) auto imgui = wxGetApp().imgui(); if (imgui->update_key_data(evt)) { render(); - } else - if (evt.GetEventType() == wxEVT_KEY_UP) { - if (m_tab_down && keyCode == WXK_TAB && !evt.HasAnyModifiers()) { - // Enable switching between 3D and Preview with Tab - // m_canvas->HandleAsNavigationKey(evt); // XXX: Doesn't work in some cases / on Linux - post_event(SimpleEvent(EVT_GLCANVAS_TAB)); - } else if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && keyCode == WXK_SHIFT && m_gizmos.gizmo_event(SLAGizmoEventType::ShiftUp)) { - // shift has been just released - SLA gizmo might want to close rectangular selection. - m_dirty = true; + } + else + { + if (!m_gizmos.on_key(evt, *this)) + { + if (evt.GetEventType() == wxEVT_KEY_UP) { + if (m_tab_down && keyCode == WXK_TAB && !evt.HasAnyModifiers()) { + // Enable switching between 3D and Preview with Tab + // m_canvas->HandleAsNavigationKey(evt); // XXX: Doesn't work in some cases / on Linux + post_event(SimpleEvent(EVT_GLCANVAS_TAB)); + } + } + else if (evt.GetEventType() == wxEVT_KEY_DOWN) { + m_tab_down = keyCode == WXK_TAB && !evt.HasAnyModifiers(); + } } - } else if (evt.GetEventType() == wxEVT_KEY_DOWN) { - m_tab_down = keyCode == WXK_TAB && !evt.HasAnyModifiers(); } if (keyCode != WXK_TAB diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 23e420489..e1a1300ba 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -660,7 +660,6 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas) int keyCode = evt.GetKeyCode(); int ctrlMask = wxMOD_CONTROL; - const Selection& selection = canvas.get_selection(); bool processed = false; if ((evt.GetModifiers() & ctrlMask) != 0) @@ -732,7 +731,7 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas) if (!processed) { - if (handle_shortcut(keyCode, selection)) + if (handle_shortcut(keyCode, canvas.get_selection())) { canvas.update_gizmos_data(); processed = true; @@ -745,6 +744,24 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas) return processed; } +bool GLGizmosManager::on_key(wxKeyEvent& evt, GLCanvas3D& canvas) +{ + const int keyCode = evt.GetKeyCode(); + bool processed = false; + + if (evt.GetEventType() == wxEVT_KEY_UP) + { + if ((m_current == SlaSupports) && (keyCode == WXK_SHIFT) && gizmo_event(SLAGizmoEventType::ShiftUp)) + // shift has been just released - SLA gizmo might want to close rectangular selection. + processed = true; + } + + if (processed) + canvas.set_as_dirty(); + + return processed; +} + void GLGizmosManager::reset() { for (GizmosMap::value_type& gizmo : m_gizmos) diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp index e269ce5ff..348cc2687 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp @@ -154,6 +154,7 @@ public: bool on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas); bool on_char(wxKeyEvent& evt, GLCanvas3D& canvas); + bool on_key(wxKeyEvent& evt, GLCanvas3D& canvas); private: void reset();