Code: Select all
bool wxEvtHandler::ProcessEvent(wxEvent& event)
{
// The very first thing we do is to allow any registered filters to hook
// into event processing in order to globally pre-process all events.
//
// Note that we should only do it if we're the first event handler called
// to avoid calling FilterEvent() multiple times as the event goes through
// the event handler chain and possibly upwards the window hierarchy.
if ( !event.WasProcessed() )
{
for ( wxEventFilter* f = ms_filterList; f; f = f->m_next )
{
int rc = f->FilterEvent(event);
if ( rc != wxEventFilter::Event_Skip )
{
wxASSERT_MSG( rc == wxEventFilter::Event_Ignore ||
rc == wxEventFilter::Event_Processed,
"unexpected FilterEvent() return value" );
return rc != wxEventFilter::Event_Ignore;
}
//else: proceed normally
}
}
// Short circuit the event processing logic if we're requested to process
// this event in this handler only, see DoTryChain() for more details.
if ( event.ShouldProcessOnlyIn(this) )
return TryBeforeAndHere(event);
// Try to process the event in this handler itself.
if ( ProcessEventLocally(event) )
{
// It is possible that DoTryChain() called from ProcessEventLocally()
// returned true but the event was not really processed: this happens
// if a custom handler ignores the request to process the event in this
// handler only and in this case we should skip the post processing
// done in TryAfter() but still return the correct value ourselves to
// indicate whether we did or did not find a handler for this event.
return !event.GetSkipped();
}
// If we still didn't find a handler, propagate the event upwards the
// window chain and/or to the application object.
if ( TryAfter(event) )
return true;
// No handler found anywhere, bail out.
return false;
}
Ideally I would like to forward the paint event, and do the idle logic after it.
Something strange about wxWidgets is its filter-like handlers aren't recursive. What I mean, is in the event handlers, you're supposed to call "Skip" to get the base functionality. But that doesn't do a damn thing. Ideally calling Skip would execute the base functionality, so that the handler is able to do its logic before or after the event. But wxWidgets doesn't give you that option. Usually doing after is preferred, but wxWidget's workflow only let's you insert logic before.
In these cases, how do you coax the event processing to happen before? There are two different contexts.
The documentation doesn't appear to say. Inside FilterEvent you'd expect ProcessEvent to work, and then return the Event_Processed to communicate the filter dispatched the event. There are many things to try, but nothing works. Everything I try appears to discard the event.
So if I want to insert logic after, presently the best I can come up with is to set a static variable to be able to check it when the next event comes through the filter. That's not a good situation to be in.
If you investigate the above code, you might get the impression you can do "WasProcessed" to cancel its filter function, and then do ProcessEvent to get the regular functionality. But that doesn't work. It's not hard to see why. I assume that setting short-circuits all processing. But what else is there to do? How to get standard processing?