Fix menu event handlers calling order.
Pass the menu event to the window associated with the menu first, before falling back on wxApp. This required adding yet another flag to keep state in wxEvent but it seems to be unavoidable as wxMenuBase::SendEvent() calls ProcessEvent() twice and we must have some way to distinguish the first call from the second one. Added a test case verifying that the menu events are indeed processed in the expected order. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73921 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -370,6 +370,7 @@ wxEvent::wxEvent(int theId, wxEventType commandType)
|
||||
m_isCommandEvent = false;
|
||||
m_propagationLevel = wxEVENT_PROPAGATE_NONE;
|
||||
m_wasProcessed = false;
|
||||
m_willBeProcessedAgain = false;
|
||||
}
|
||||
|
||||
wxEvent::wxEvent(const wxEvent& src)
|
||||
@@ -384,6 +385,7 @@ wxEvent::wxEvent(const wxEvent& src)
|
||||
, m_skipped(src.m_skipped)
|
||||
, m_isCommandEvent(src.m_isCommandEvent)
|
||||
, m_wasProcessed(false)
|
||||
, m_willBeProcessedAgain(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -403,6 +405,10 @@ wxEvent& wxEvent::operator=(const wxEvent& src)
|
||||
|
||||
// don't change m_wasProcessed
|
||||
|
||||
// While the original again could be passed to another handler, this one
|
||||
// isn't going to be processed anywhere else by default.
|
||||
m_willBeProcessedAgain = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -1428,6 +1434,12 @@ bool wxEvtHandler::TryAfter(wxEvent& event)
|
||||
if ( GetNextHandler() )
|
||||
return GetNextHandler()->TryAfter(event);
|
||||
|
||||
// If this event is going to be processed in another handler next, don't
|
||||
// pass it to wxTheApp now, it will be done from TryAfter() of this other
|
||||
// handler.
|
||||
if ( event.WillBeProcessedAgain() )
|
||||
return false;
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_8
|
||||
// as above, call the old virtual function for compatibility
|
||||
return TryParent(event);
|
||||
|
Reference in New Issue
Block a user