diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index ab034168b6..e25cf41511 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -79,6 +79,13 @@ #include +#ifdef __WXMSW__ +#if wxUSE_POPUPWIN +#include +extern wxPopupWindow* wxCurrentPopupWindow; +#endif +#endif + static constexpr const float TRACKBALLSIZE = 0.8f; static Slic3r::ColorRGBA DEFAULT_BG_LIGHT_COLOR = { 0.906f, 0.906f, 0.906f, 1.0f }; @@ -4258,14 +4265,21 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (evt.Entering()) { // Set focus in order to remove it from sidebar fields and ensure hotkeys work if (m_canvas != nullptr) { - // Only set focus if the top level window of this canvas is active. - auto p = dynamic_cast(evt.GetEventObject()); - while (p->GetParent()) - p = p->GetParent(); - auto *top_level_wnd = dynamic_cast(p); - //Orca: Set focus so hotkeys like 'tab' work when a notification is shown. - if (top_level_wnd != nullptr && top_level_wnd->IsActive()) - m_canvas->SetFocus(); +#if defined(__WXMSW__) && wxUSE_POPUPWIN + // Don't steal focus when a popup window is active (e.g., search dropdown). + // Stealing focus triggers MSWDismissUnfocusedPopup, closing the popup unexpectedly. + if (!wxCurrentPopupWindow) +#endif + { + // Only set focus if the top level window of this canvas is active. + auto p = dynamic_cast(evt.GetEventObject()); + while (p->GetParent()) + p = p->GetParent(); + auto *top_level_wnd = dynamic_cast(p); + //Orca: Set focus so hotkeys like 'tab' work when a notification is shown. + if (top_level_wnd != nullptr && top_level_wnd->IsActive()) + m_canvas->SetFocus(); + } 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