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
This commit is contained in:
parent
341d8cb2cf
commit
7739f9c947
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user