From 051ca410f675b20e2829fdfc96342571abf04427 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 21 Feb 2019 18:31:01 +0100 Subject: [PATCH] More input handling fixes --- src/slic3r/GUI/GLCanvas3D.cpp | 17 +++++++++++++---- src/slic3r/GUI/GLCanvas3D.hpp | 1 + src/slic3r/GUI/GUI_Preview.cpp | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index ad19b08bd..b194ba138 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4119,6 +4119,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas) , m_multisample_allowed(false) , m_regenerate_volumes(true) , m_moving(false) + , m_tab_down(false) , m_color_by("volume") , m_reload_delayed(false) , m_render_sla_auxiliaries(true) @@ -5314,6 +5315,8 @@ void GLCanvas3D::on_char(wxKeyEvent& evt) void GLCanvas3D::on_key(wxKeyEvent& evt) { + const int keyCode = evt.GetKeyCode(); + #if ENABLE_IMGUI auto imgui = wxGetApp().imgui(); if (imgui->update_key_data(evt)) { @@ -5321,9 +5324,7 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) } else #endif // ENABLE_IMGUI if (evt.GetEventType() == wxEVT_KEY_UP) { - const int keyCode = evt.GetKeyCode(); - - if (keyCode == WXK_TAB) { + 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)); @@ -5331,9 +5332,17 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) // shift has been just released - SLA gizmo might want to close rectangular selection. m_dirty = true; } + } else if (evt.GetEventType() == wxEVT_KEY_DOWN) { + m_tab_down = keyCode == WXK_TAB && !evt.HasAnyModifiers(); } - evt.Skip(); // Needed to have EVT_CHAR generated as well + if (keyCode != WXK_TAB + && keyCode != WXK_LEFT + && keyCode != WXK_UP + && keyCode != WXK_RIGHT + && keyCode != WXK_DOWN) { + evt.Skip(); // Needed to have EVT_CHAR generated as well + } } void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt) diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index ff136e190..f3e1bc918 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -946,6 +946,7 @@ private: bool m_multisample_allowed; bool m_regenerate_volumes; bool m_moving; + bool m_tab_down; bool m_render_sla_auxiliaries; std::string m_color_by; diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index f730496ce..b311cde51 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -52,7 +52,7 @@ View3D::~View3D() bool View3D::init(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process) { - if (!Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)) + if (!Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 /* disable wxTAB_TRAVERSAL */)) return false; m_canvas_widget = GLCanvas3DManager::create_wxglcanvas(this);