From b85e80c4fb49277a7e2cb9a047908aad0f8c59af Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 26 Jan 2024 14:12:33 +0100 Subject: [PATCH] Fix for #11988 : Drop down menus appear outside of PS and cannot be opened again Note: Win specific --- src/slic3r/GUI/Sidebar.cpp | 28 ++++++++++++++++++++++++++++ src/slic3r/GUI/Widgets/DropDown.hpp | 2 ++ 2 files changed, 30 insertions(+) diff --git a/src/slic3r/GUI/Sidebar.cpp b/src/slic3r/GUI/Sidebar.cpp index 4f6be2b61f..11eabb7f0a 100644 --- a/src/slic3r/GUI/Sidebar.cpp +++ b/src/slic3r/GUI/Sidebar.cpp @@ -250,10 +250,38 @@ static wxRichToolTipPopup* get_rtt_popup(wxButton* btn) return nullptr; } +// Help function to find and check if some combobox is dropped down and then dismiss it +static bool found_and_dismiss_shown_dropdown(wxWindow* win) +{ + auto children = win->GetChildren(); + if (children.IsEmpty()) { + if (auto dd = dynamic_cast(win); dd && dd->IsShown()) { + dd->CallDismissAndNotify(); + return true; + } + } + + for (auto child : children) { + if (found_and_dismiss_shown_dropdown(child)) + return true; + } + return false; +} + static void show_rich_tip(const wxString& tooltip, wxButton* btn) { if (tooltip.IsEmpty()) return; + + // Currently state (propably wxWidgets issue) : + // When second wxPopupTransientWindow is popped up, then first wxPopupTransientWindow doesn't receive EVT_DISMISS and stay on the top. + // New comboboxes use wxPopupTransientWindow as DropDown now + // That is why DropDown stay on top, when we show rich tooltip for btn. + // (see https://github.com/prusa3d/PrusaSlicer/issues/11988) + + // So, check the combo boxes and close them if necessary before showing the rich tip. + found_and_dismiss_shown_dropdown(btn->GetParent()); + wxRichToolTip tip(tooltip, ""); tip.SetIcon(wxICON_NONE); tip.SetTipKind(wxTipKind_BottomRight); diff --git a/src/slic3r/GUI/Widgets/DropDown.hpp b/src/slic3r/GUI/Widgets/DropDown.hpp index 8a4757f5f7..8d17ea658d 100644 --- a/src/slic3r/GUI/Widgets/DropDown.hpp +++ b/src/slic3r/GUI/Widgets/DropDown.hpp @@ -86,6 +86,8 @@ public: bool HasDismissLongTime(); static void SetTransparentBG(wxDC& dc, wxWindow* win); + + void CallDismissAndNotify() { DismissAndNotify(); } protected: void OnDismiss() override;