- // propagate the event upwards the window chain and/or to the application
- // object if it wasn't processed at this level
- return TryAfter(event);
+bool wxEvtHandler::DoTryChain(wxEvent& event)
+{
+ for ( wxEvtHandler *h = GetNextHandler(); h; h = h->GetNextHandler() )
+ {
+ // We need to process this event at the level of this handler only
+ // right now, the pre-/post-processing was either already done by
+ // ProcessEvent() from which we were called or will be done by it when
+ // we return.
+ //
+ // However we must call ProcessEvent() and not ProcessEventHere()
+ // because the existing code (including some in wxWidgets itself)
+ // expects the overridden ProcessEvent() in its custom event handlers
+ // pushed on a window to be called.
+ //
+ // So we must call ProcessEvent() but it must not do what it usually
+ // does. To resolve this paradox we pass a special "process here only"
+ // flag to ProcessEvent() via the event object itself. This ensures
+ // that if our own, base class, version is called, it will just call
+ // ProcessEventHere() and won't do anything else, just as we want it to.
+ wxEventProcessHereOnly processHereOnly(event);
+ if ( h->ProcessEvent(event) )
+ return true;
+ }
+
+ return false;