From: Vadim Zeitlin Date: Sat, 29 Jun 2013 12:53:44 +0000 (+0000) Subject: Forward events to active child in wxMDIParentFrameBase, not only wxMSW. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6f65a5e1aa7e69de4ab41b62085a7419d58b52d9 Forward events to active child in wxMDIParentFrameBase, not only wxMSW. Menu, toolbar and update UI events should be forwarded to the active child under all platforms in MDI applications and not only MSW, so move TryBefore() overload from wxMSW wxMDIParentFrame to wxMDIParentFrameBase. This should make things more consistent in general and notably fixes the lack of toolbar events in wxDocChildFrame since the changes of r73928. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74314 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/mdi.h b/include/wx/mdi.h index 19a8832fb6..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 @@ -369,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_ diff --git a/include/wx/msw/mdi.h b/include/wx/msw/mdi.h index caf235fd56..afef0664a4 100644 --- a/include/wx/msw/mdi.h +++ b/include/wx/msw/mdi.h @@ -110,9 +110,6 @@ public: #endif // wxUSE_MENUS protected: - // override to pass menu/toolbar events to the active child first - virtual bool TryBefore(wxEvent& event); - #if wxUSE_MENUS_NATIVE virtual void InternalSetMenuBar(); #endif // wxUSE_MENUS_NATIVE diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index e78625d9f0..309002bb01 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -698,21 +698,6 @@ void wxMDIParentFrame::OnMDICommand(wxCommandEvent& event) #endif // wxUSE_MENUS -bool wxMDIParentFrame::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 wxMDIParentFrameBase::TryBefore(event); -} - WXLRESULT wxMDIParentFrame::MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)