X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6dd0883d556cbed9d47b08c12682ef233717c097..d642db66a5efc82d374b813022c72ba88bc50839:/include/wx/mdi.h?ds=sidebyside diff --git a/include/wx/mdi.h b/include/wx/mdi.h index 1f5d56e647..78c2f4c3e4 100644 --- a/include/wx/mdi.h +++ b/include/wx/mdi.h @@ -123,6 +123,10 @@ public: virtual wxMDIClientWindow *OnCreateClient(); protected: + // Override to pass menu/toolbar events to the active child first. + virtual bool TryBefore(wxEvent& event); + + // This is wxMDIClientWindow for all the native implementations but not for // the generic MDI version which has its own wxGenericMDIClientWindow and // so we store it as just a base class pointer because we don't need its @@ -181,6 +185,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; }; @@ -364,6 +373,21 @@ inline wxMDIClientWindow *wxMDIParentFrameBase::OnCreateClient() return new wxMDIClientWindow; } +inline bool wxMDIParentFrameBase::TryBefore(wxEvent& event) +{ + // Menu (and toolbar) events should be sent to the active child frame + // first, if any. + if ( event.GetEventType() == wxEVT_MENU || + event.GetEventType() == wxEVT_UPDATE_UI ) + { + wxMDIChildFrame * const child = GetActiveChild(); + if ( child && child->ProcessWindowEventLocally(event) ) + return true; + } + + return wxFrame::TryBefore(event); +} + #endif // wxUSE_MDI #endif // _WX_MDI_H_BASE_