From da787f5bae9cf54972e80b6a01323da302fc21b4 Mon Sep 17 00:00:00 2001 From: Blake-Madden <66873089+Blake-Madden@users.noreply.github.com> Date: Sun, 24 Nov 2024 16:52:49 -0500 Subject: [PATCH] Don't use the mainframe as a parent if hidden, try to use the active doc window first --- src/ui/mainframe.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ui/mainframe.cpp b/src/ui/mainframe.cpp index b384590c..ab8171d6 100644 --- a/src/ui/mainframe.cpp +++ b/src/ui/mainframe.cpp @@ -88,7 +88,21 @@ wxDocTemplate* Wisteria::UI::DocManager::SelectDocumentType(wxDocTemplate** temp docNames.Add(data[i]->GetDescription()); } // find a suitable parent window - RadioBoxDlg radioDlg(wxTheApp->GetTopWindow(), _(L"Select Project Type"), wxEmptyString, + wxWindow* parentWindow = + [this]() + { + if (wxTheApp->GetTopWindow() != nullptr && wxTheApp->GetTopWindow()->IsShown()) + { + return wxTheApp->GetTopWindow(); + } + else if (GetCurrentDocument() != nullptr && + GetCurrentDocument()->GetDocumentWindow() != nullptr) + { + return GetCurrentDocument()->GetDocumentWindow(); + } + return wxTheApp->GetTopWindow(); + }(); + RadioBoxDlg radioDlg(parentWindow, _(L"Select Project Type"), wxString{}, _(L"Project types:"), _(L"New Project"), docNames, docDescriptions); if (radioDlg.ShowModal() == wxID_OK) {