Fix recently broken forwarding of events between event handlers.
After the recent changes to the event processing logic, forwarding an event from one event handler to another one stopped working correctly because the per-event "process here only" flag prevented it from following the event handler chain after forwarding. This notably broke keyboard navigation in wxComboCtrl under MSW in wx itself and probably quite a few of other things in user code. Fix this by replacing the boolean flag with a pointer to the handler to which the processing of this event should be restricted. This allows the full processing to still take place if an event is forwarded to another handler. So wxEvent::ShouldProcessHereOnly() is now called ShouldProcessOnlyIn() and takes a wxEvtHandler parameter. This made appear a problem in wxScrollHelperEvtHandler code that was hidden by the bug above: the events were still processed multiple times in it. To fix this, also add wxEvent::DidntHonourProcessOnlyIn() and take it into account in the base class code. Did I mention that wxScrollHelperEvtHandler must die? Add another unit test checking that forwarding works correctly. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64464 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -209,11 +209,6 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
|
||||
// (as indicated by "process here only" flag being set) and we do want to
|
||||
// execute the handler defined in the window we're associated with right
|
||||
// now, without waiting until TryAfter() is called from wxEvtHandler.
|
||||
//
|
||||
// Note that this means that the handler in the window will be called twice
|
||||
// if there is a preceding event handler in the chain because we do it from
|
||||
// here now and the base class DoTryChain() will also call it itself when
|
||||
// we return. But this unfortunately seems unavoidable.
|
||||
bool processed = m_nextHandler->ProcessEvent(event);
|
||||
|
||||
// always process the size events ourselves, even if the user code handles
|
||||
@@ -310,6 +305,17 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
|
||||
|
||||
event.Skip(wasSkipped);
|
||||
|
||||
// We called ProcessEvent() on the next handler, meaning that we explicitly
|
||||
// worked around the request to process the event in this handler only. As
|
||||
// explained above, this is unfortunately really necessary but the trouble
|
||||
// is that the event will continue to be post-processed by the previous
|
||||
// handler resulting in duplicate calls to event handlers. Call the special
|
||||
// function below to prevent this from happening, base class DoTryChain()
|
||||
// will check for it and behave accordingly.
|
||||
//
|
||||
// And if we're not called from DoTryChain(), this won't do anything anyhow.
|
||||
event.DidntHonourProcessOnlyIn();
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user