From 3285e9a347c8b67774de6110444ed50bd6b8cd21 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Mar 2012 00:29:03 +0000 Subject: [PATCH] Fix showing MDI child from wxDocManager::ActivateDocument(). This fix has 2 components: first, call Raise() instead of simple SetFocus() from ActivateDocument() as this corresponds better to what we want to do here. And second, override Raise() to call Activate() in wxMDIChildFrame to ensure that it works as expected as raising an MDI child doesn't work otherwise in most ports (with the exceptions for wxOSX which, on the contrary, needs a small fix to preserve the existing working Raise() behaviour). Closes #13946. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70790 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mdi.h | 5 +++++ src/common/docview.cpp | 2 +- src/osx/carbon/mdi.cpp | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/wx/mdi.h b/include/wx/mdi.h index 1f5d56e..19a8832 100644 --- a/include/wx/mdi.h +++ b/include/wx/mdi.h @@ -181,6 +181,11 @@ public: // return true. virtual bool IsTopNavigationDomain() const { return true; } + // Raising any frame is supposed to show it but wxFrame Raise() + // implementation doesn't work for MDI child frames in most forms so + // forward this to Activate() which serves the same purpose by default. + virtual void Raise() { Activate(); } + protected: wxMDIParentFrame *m_mdiParent; }; diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 5df2030..0154cbd 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -1414,7 +1414,7 @@ void wxDocManager::ActivateDocument(wxDocument *doc) view->Activate(true); if ( wxWindow *win = view->GetFrame() ) - win->SetFocus(); + win->Raise(); } wxDocument *wxDocManager::CreateDocument(const wxString& pathOrig, long flags) diff --git a/src/osx/carbon/mdi.cpp b/src/osx/carbon/mdi.cpp index 216c168..80f31dc 100644 --- a/src/osx/carbon/mdi.cpp +++ b/src/osx/carbon/mdi.cpp @@ -417,7 +417,9 @@ void wxMDIChildFrame::MacActivate(long timestamp, bool activating) // MDI operations void wxMDIChildFrame::Activate() { - Raise (); + // The base class method calls Activate() so skip it to avoid infinite + // recursion and go directly to the real Raise() implementation. + wxFrame::Raise(); } //----------------------------------------------------------------------------- -- 2.7.4