X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3285e9a347c8b67774de6110444ed50bd6b8cd21..661698e54f2bc599dc1a961ffbae08ccdd6b9b97:/include/wx/mdi.h diff --git a/include/wx/mdi.h b/include/wx/mdi.h index 19a8832fb6..52cbed7da4 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 @@ -369,6 +373,31 @@ 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 ) + { + // However avoid sending the event back to the child if it's + // currently being propagated to us from it. + wxWindow* const + from = static_cast(event.GetPropagatedFrom()); + if ( !from || !from->IsDescendant(child) ) + { + if ( child->ProcessWindowEventLocally(event) ) + return true; + } + } + } + + return wxFrame::TryBefore(event); +} + #endif // wxUSE_MDI #endif // _WX_MDI_H_BASE_