A global event filter for pre-processing all the events generated in the program.
This is a very simple class which just provides FilterEvent() virtual method to be called by wxEvtHandler before starting process of any event. Thus, inheriting from this class and overriding FilterEvent() allows to capture and possibly handle or ignore all the events happening in the program. Of course, having event filters adds additional overhead to every event processing and so should not be used lightly and your FilterEvent() code should try to return as quickly as possible, especially for the events it is not interested in.
An example of using this class:
Notice that wxApp derives from wxEventFilter and is registered as an event filter during its creation so you may also override FilterEvent() method in your wxApp-derived class and, in fact, this is often the most convenient way to do it. However creating a new class deriving directly from wxEventFilter allows to isolate the event filtering code in its own separate class and also to have several independent filters, if necessary.
Event_Skip = -1,
Event_Ignore = 0,
Event_Processed = 1
|Possible return values for FilterEvent(). More...|
|Default constructor. |
|virtual int||FilterEvent (wxEvent &event)=0|
|Override this method to implement event pre-processing. |
Possible return values for FilterEvent().
Constructor does not register this filter using wxEvtHandler::AddFilter(), it's your responsibility to do it when necessary.
Notice that the objects of this class can't be copied.
You must call wxEvtHandler::RemoveFilter() before destroying this object (possibly from the derived class destructor), failure to do this is indicated by an assert unless assertions are disabled.
Override this method to implement event pre-processing.
This method allows to filter all the events processed by the program, so you should try to return quickly from it to avoid slowing down the program to a crawl.
Although the return type of this method is
int, this is only due to backwards compatibility concerns and the actual return value must be one of the
Event_XXX constants defined above:
Implemented in wxAppConsole.