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;