]> git.saurik.com Git - wxWidgets.git/commitdiff
Forward events to active child at MSW, not wx, level in wxMDIParentFrame.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 4 May 2013 23:59:51 +0000 (23:59 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 4 May 2013 23:59:51 +0000 (23:59 +0000)
We want to handle menu (and toolbar) events in the active MDI child before
handling them in the parent frame itself and the existing code achieved this
by forwarding wxEVT_MENU events at wx event processing level to the active
child. However this was not enough as the underlying MSW WM_COMMAND message
was still sent to the parent frame only and this could result in wx event not
being generated at all if the parent frame had a disabled menu item with the
same ID as (an enabled) item in the child frame, see #14314.

So forward WM_COMMAND directly to ensure that the correct window gets the
event in the first place. And this makes wxEVT_MENU forwarding in TryBefore()
unnecessary.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73927 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/mdi.h
src/msw/mdi.cpp

index caf235fd56a68ec7578df102d48bf70b0cdef00d..afef0664a4b7567c071aac1622a11a7da612c141 100644 (file)
@@ -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
index db1997bdd6f7aa465e8c0ddb420e27aeddd86ae7..6ecd832ea5358c012073253ea7880d6c77789540 100644 (file)
@@ -577,6 +577,19 @@ WXLRESULT wxMDIParentFrame::MSWWindowProc(WXUINT message,
                     MSWDefWindowProc(message, wParam, lParam);
                     processed = true;
                 }
+                else // Not a system command.
+                {
+                    // Menu (and toolbar) events should be sent to the active
+                    // child first and only be processed by the parent frame if
+                    // they're not handled there.
+                    if ( wxMDIChildFrame* child = GetActiveChild() )
+                    {
+                        processed = child->MSWHandleMessage(&rc,
+                                                            message,
+                                                            wParam,
+                                                            lParam);
+                    }
+                }
             }
             break;
 
@@ -695,20 +708,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 )
-    {
-        wxMDIChildFrame * const child = GetActiveChild();
-        if ( child && child->ProcessWindowEventLocally(event) )
-            return true;
-    }
-
-    return wxMDIParentFrameBase::TryBefore(event);
-}
-
 WXLRESULT wxMDIParentFrame::MSWDefWindowProc(WXUINT message,
                                         WXWPARAM wParam,
                                         WXLPARAM lParam)