From 7739f9c947aa1d7ad2a0c70a112fed820f909d96 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 24 Apr 2010 15:07:55 +0000 Subject: [PATCH] Use wxMenu::GetWindow() instead of GetInvokingWindow() in SendEvent(). This simplifies the code as we don't need to walk the menu hierarchy upwards any more (GetInvokingWindow() does it now) and also makes it work for all menus, not just the popup ones. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64126 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/menucmn.cpp | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 74d5fd843d..0d2d14bf0a 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -453,30 +453,17 @@ bool wxMenuBase::SendEvent(int id, int checked) bool processed = false; - // Try the menu's event handler - // if ( !processed ) - { - wxEvtHandler *handler = GetEventHandler(); - if ( handler ) - processed = handler->SafelyProcessEvent(event); - } + // Try the menu's event handler first + wxEvtHandler *handler = GetEventHandler(); + if ( handler ) + processed = handler->SafelyProcessEvent(event); - // Try the window the menu was popped up from (and up through the - // hierarchy) + // Try the window the menu was popped up from or its menu bar belongs to if ( !processed ) { - const wxMenuBase *menu = this; - while ( menu ) - { - wxWindow *win = menu->GetInvokingWindow(); - if ( win ) - { - processed = win->HandleWindowEvent(event); - break; - } - - menu = menu->GetParent(); - } + wxWindow * const win = GetWindow(); + if ( win ) + processed = win->HandleWindowEvent(event); } return processed; -- 2.47.2