From 358e9f2f72eb48f077dc145035a34548ebc2b7de Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 22 Sep 2008 14:11:40 +0000 Subject: [PATCH 1/1] fix the event handling in presence of pushed event handlers broken by r55784 (closes #9992) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55795 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/doxygen/overviews/eventhandling.h | 18 +++++++++++------- src/common/event.cpp | 7 +++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/doxygen/overviews/eventhandling.h b/docs/doxygen/overviews/eventhandling.h index 9618a50ee0..80cc860fe1 100644 --- a/docs/doxygen/overviews/eventhandling.h +++ b/docs/doxygen/overviews/eventhandling.h @@ -332,17 +332,21 @@ doesn't count as having handled the event and the search continues):
  • The event is passed to the next event handler, if any, in the event handler - chain. This chain can be formed using wxEvtHandler::SetNextHandler() or - wxWindow::PushEventHandler() but usually there is no next event handler and - chaining event handlers using these functions is much less useful now that - Connect() exists so this step will almost never do anything. + chain, i.e. the steps (1) to (4) are done for it. This chain can be formed + using wxEvtHandler::SetNextHandler() or wxWindow::PushEventHandler() but + usually there is no next event handler and chaining event handlers using + these functions is much less useful now that Connect() exists so this step + will almost never do anything.
  • - If the object is a wxWindow and the event is set to set to propagate (by - default only wxCommandEvent-derived events are set to propagate), then the + If the object is a wxWindow and the event is set to propagate (by default + only wxCommandEvent-derived events are set to propagate), then the processing restarts from the step (1) (and excluding the step (7)) for the - parent window. + parent window. If this object is not a window but the next handler exists, + the event is passed to its parent if it is a window. This ensures that in a + common case of (possibly several) non-window event handlers pushed on top + of a window, the event eventually reaches the window parent.
  • diff --git a/src/common/event.cpp b/src/common/event.cpp index 6c504bc51c..d05742d1fd 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -1273,6 +1273,13 @@ wxEvtHandler::ProcessEventIfMatches(const wxEventTableEntryBase& entry, bool wxEvtHandler::TryParent(wxEvent& event) { + if ( GetNextHandler() ) + { + // the next handler will pass it to wxTheApp if it doesn't process it, + // so return from here to avoid doing it again + return GetNextHandler()->TryParent(event); + } + if ( wxTheApp && (this != wxTheApp) ) { // Special case: don't pass wxEVT_IDLE to wxApp, since it'll always -- 2.45.2