Browse Source

Revert "Revert "Fix for #11988 : Drop down menus appear outside of PS and cannot be opened again""
This reverts commit 69e0bc3064298fc58dd2a870801161821fa16da5.
The reason the original commit was reverted was to get cleaner git history after
merging master_27x into master. The change in this commit is implemented in master as b85e80c.

Lukas Matena 1 year ago
parent
commit
e5b926690e
2 changed files with 30 additions and 0 deletions
  1. 28 0
      src/slic3r/GUI/Plater.cpp
  2. 2 0
      src/slic3r/GUI/Widgets/DropDown.hpp

+ 28 - 0
src/slic3r/GUI/Plater.cpp

@@ -753,10 +753,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<DropDown*>(win); dd && dd->IsShown()) {
+            dd->CallDismissAndNotify();
+            return true;
+        }
+    }
+
+    for (auto child : children) {
+        if (found_and_dismiss_shown_dropdown(child))
+            return true;
+    }
+    return false;
+}
+
 void Sidebar::priv::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(scrolled);
+
     wxRichToolTip tip(tooltip, "");
     tip.SetIcon(wxICON_NONE);
     tip.SetTipKind(wxTipKind_BottomRight);

+ 2 - 0
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;