diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index f82e5edcf8..fd3258e61e 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -58,6 +58,8 @@ #define ENABLE_PREVIEW_LAYER_TIME (1 && ENABLE_2_5_0_ALPHA1) // Enable showing time estimate for travel moves in legend #define ENABLE_TRAVEL_TIME (1 && ENABLE_2_5_0_ALPHA1) +// Enable not killing focus in object manipulator fields when hovering over 3D scene +#define ENABLE_OBJECT_MANIPULATOR_FOCUS (1 && ENABLE_2_5_0_ALPHA1) #endif // _prusaslicer_technologies_h_ diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 9e83fb2a42..67e1b8bcf5 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2934,6 +2934,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp()) mouse_up_cleanup(); m_mouse.set_start_position_3D_as_invalid(); +#if ENABLE_OBJECT_MANIPULATOR_FOCUS + handle_sidebar_focus_event("", false); +#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS return; } @@ -2941,6 +2944,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp()) mouse_up_cleanup(); m_mouse.set_start_position_3D_as_invalid(); +#if ENABLE_OBJECT_MANIPULATOR_FOCUS + handle_sidebar_focus_event("", false); +#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS return; } @@ -2948,6 +2954,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp()) mouse_up_cleanup(); m_mouse.set_start_position_3D_as_invalid(); +#if ENABLE_OBJECT_MANIPULATOR_FOCUS + handle_sidebar_focus_event("", false); +#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS return; } @@ -2955,6 +2964,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp()) mouse_up_cleanup(); m_mouse.set_start_position_3D_as_invalid(); +#if ENABLE_OBJECT_MANIPULATOR_FOCUS + handle_sidebar_focus_event("", false); +#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS return; } @@ -3008,6 +3020,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } +#if ENABLE_OBJECT_MANIPULATOR_FOCUS + handle_sidebar_focus_event("", false); +#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS return; } @@ -3022,15 +3037,27 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_mouse.set_move_start_threshold_position_2D_as_invalid(); } +#if ENABLE_OBJECT_MANIPULATOR_FOCUS + if (evt.ButtonDown()) { + handle_sidebar_focus_event("", false); + if (wxWindow::FindFocus() != m_canvas) + // Grab keyboard focus on any mouse click event. + m_canvas->SetFocus(); + } +#else if (evt.ButtonDown() && wxWindow::FindFocus() != m_canvas) // Grab keyboard focus on any mouse click event. m_canvas->SetFocus(); +#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS if (evt.Entering()) { //#if defined(__WXMSW__) || defined(__linux__) // // On Windows and Linux needs focus in order to catch key events +#if !ENABLE_OBJECT_MANIPULATOR_FOCUS // Set focus in order to remove it from sidebar fields +#endif // !ENABLE_OBJECT_MANIPULATOR_FOCUS if (m_canvas != nullptr) { +#if !ENABLE_OBJECT_MANIPULATOR_FOCUS // Only set focus, if the top level window of this canvas is active. auto p = dynamic_cast(evt.GetEventObject()); while (p->GetParent()) @@ -3038,6 +3065,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) auto *top_level_wnd = dynamic_cast(p); if (top_level_wnd && top_level_wnd->IsActive()) m_canvas->SetFocus(); +#endif // !ENABLE_OBJECT_MANIPULATOR_FOCUS m_mouse.position = pos.cast(); m_tooltip_enabled = false; // 1) forces a frame render to ensure that m_hover_volume_idxs is updated even when the user right clicks while diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index 18e58efb88..4c1615dd46 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -1103,9 +1103,14 @@ ManipulationEditor::ManipulationEditor(ObjectManipulation* parent, { parent->set_focused_editor(nullptr); +#if ENABLE_OBJECT_MANIPULATOR_FOCUS + // if the widget loosing focus is not a manipulator field, call kill_focus + if (dynamic_cast(e.GetWindow()) == nullptr) +#else if (!m_enter_pressed) +#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS kill_focus(parent); - + e.Skip(); }, this->GetId());