Recurse upwards the menu hierarchy in wxMenu::GetWindow().
Only the top level menus have non-NULL wxMenuBar pointer too, so recurse upwards the menu hierarchy in GetWindow() and not (just) GetInvokingWindow(). This fixes event processing for submenus broken by the recent changes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64135 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -256,11 +256,11 @@ public:
|
||||
wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
|
||||
|
||||
// Invoking window: this is set by wxWindow::PopupMenu() before showing a
|
||||
// popup menu and reset after it's hidden. Notice that GetInvokingWindow()
|
||||
// recurses upwards and will return the invoking window for any submenu of
|
||||
// a popup menu as well as the menu itself.
|
||||
// popup menu and reset after it's hidden. Notice that you probably want to
|
||||
// use GetWindow() below instead of GetInvokingWindow() as the latter only
|
||||
// returns non-NULL for the top level menus
|
||||
void SetInvokingWindow(wxWindow *win);
|
||||
wxWindow *GetInvokingWindow() const;
|
||||
wxWindow *GetInvokingWindow() const { return m_invokingWindow; }
|
||||
|
||||
// the window associated with this menu: this is the invoking window for
|
||||
// popup menus or the top level window to which the menu bar is attached
|
||||
|
@@ -514,23 +514,18 @@ void wxMenuBase::SetInvokingWindow(wxWindow *win)
|
||||
m_invokingWindow = win;
|
||||
}
|
||||
|
||||
wxWindow *wxMenuBase::GetInvokingWindow() const
|
||||
wxWindow *wxMenuBase::GetWindow() const
|
||||
{
|
||||
// only the popup menu itself has a non-NULL invoking window so recurse
|
||||
// upwards until we find it
|
||||
// only the top level menus have non-NULL invoking window or a pointer to
|
||||
// the menu bar so recurse upwards until we find it
|
||||
const wxMenuBase *menu = this;
|
||||
while ( menu->GetParent() )
|
||||
{
|
||||
menu = menu->GetParent();
|
||||
}
|
||||
|
||||
// menu is a top level menu here
|
||||
return menu->m_invokingWindow;
|
||||
}
|
||||
|
||||
wxWindow *wxMenuBase::GetWindow() const
|
||||
{
|
||||
return GetMenuBar() ? GetMenuBar()->GetFrame() : GetInvokingWindow();
|
||||
return menu->GetMenuBar() ? menu->GetMenuBar()->GetFrame()
|
||||
: menu->GetInvokingWindow();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user