From 779a36bf8b1af341ecb379483aeb25a0862bfb6e Mon Sep 17 00:00:00 2001 From: SoftFever Date: Sat, 28 Mar 2026 13:04:20 +0800 Subject: [PATCH] fix a regresion that the "search in preset" popup dialog will dismiss itself when move the cursor out of the dialog. The regression is casued by 382cf57166d ("Fix hotkeys blocked in Prepare view when notification is shown") --- src/slic3r/GUI/GLCanvas3D.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) 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