/**
@name Event-handling functions
+
+ wxWindow allows you to build a (sort of) stack of event handlers which
+ can be used to override the window's own event handling.
*/
//@{
wxEvtHandler* GetEventHandler() const;
/**
- This function will generate the appropriate call to
- Navigate() if the key event is one normally used for
- keyboard navigation and return @true in this case.
+ This function will generate the appropriate call to Navigate() if the key
+ event is one normally used for keyboard navigation and return @true in this case.
@return Returns @true if the key pressed was for navigation and was
handled, @false otherwise.
/**
Removes and returns the top-most event handler on the event handler stack.
+ E.g. in the case of:
+ @image html overview_eventhandling_winstack.png
+ when calling @c W->PopEventHandler(), the event handler @c A will be
+ removed and @c B will be the first handler of the stack.
+
+ Note that it's an error to call this function when no event handlers
+ were pushed on this window (i.e. when the window itself is its only
+ event handler).
+
@param deleteHandler
- If this is @true, the handler will be deleted after it is removed.
- The default value is @false.
+ If this is @true, the handler will be deleted after it is removed
+ (and the returned value will be @NULL).
- @see SetEventHandler(), GetEventHandler(),
- PushEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
+ @see @ref overview_eventhandling_processing
*/
wxEvtHandler* PopEventHandler(bool deleteHandler = false);
/**
Pushes this event handler onto the event stack for the window.
+ An event handler is an object that is capable of processing the events sent
+ to a window. By default, the window is its own event handler, but an application
+ may wish to substitute another, for example to allow central implementation
+ of event-handling for a variety of different window classes.
+
+ wxWindow::PushEventHandler allows an application to set up a @e stack
+ of event handlers, where an event not handled by one event handler is
+ handed to the next one in the chain.
+
+ E.g. if you have two event handlers @c A and @c B and a wxWindow instance
+ @c W and you call:
+ @code
+ W->PushEventHandler(A);
+ W->PushEventHandler(B);
+ @endcode
+ you will end up with the following situation:
+ @image html overview_eventhandling_winstack.png
+
+ Note that you can use wxWindow::PopEventHandler to remove the event handler.
+
@param handler
Specifies the handler to be pushed.
+ It must not be part of a wxEvtHandler chain; an assert will fail
+ if it's not unlinked (see wxEvtHandler::IsUnlinked).
- @remarks An event handler is an object that is capable of processing the
- events sent to a window. By default, the window is its
- own event handler, but an application may wish to
- substitute another, for example to allow central
- implementation of event-handling for a variety of
- different window classes.
- wxWindow::PushEventHandler allows an application to set up a
- chain of event handlers, where an event not handled by one event
- handler is handed to the next one in the chain.
- Use wxWindow::PopEventHandler to remove the event handler.
-
- @see SetEventHandler(), GetEventHandler(),
- PopEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
+ @see @ref overview_eventhandling_processing
*/
void PushEventHandler(wxEvtHandler* handler);
/**
- Find the given @a handler in the windows event handler chain and remove
- (but not delete) it from it.
+ Find the given @a handler in the windows event handler stack and unlinks
+ (but not delete) it. See wxEvtHandler::Unlink() for more info.
@param handler
The event handler to remove, must be non-@NULL and
- must be present in this windows event handlers chain
+ must be present in this windows event handlers stack.
@return Returns @true if it was found and @false otherwise (this also
results in an assert failure so this function should
/**
Sets the event handler for this window.
+ Note that if you use this function you may want to use as the "next" handler
+ of @a handler the window itself; in this way when @a handler doesn't process
+ an event, the window itself will have a chance to do it.
+
@param handler
- Specifies the handler to be set.
-
- @remarks An event handler is an object that is capable of processing the
- events sent to a window. By default, the window is its
- own event handler, but an application may wish to
- substitute another, for example to allow central
- implementation of event-handling for a variety of
- different window classes.
- It is usually better to use wxWindow::PushEventHandler since
- this sets up a chain of event handlers, where an event not
- handled by one event handler is handed to the next one in the chain.
-
- @see GetEventHandler(), PushEventHandler(),
- PopEventHandler(), wxEvtHandler::ProcessEvent, wxEvtHandler
+ Specifies the handler to be set. Cannot be @NULL.
+
+ @see @ref overview_eventhandling_processing
*/
void SetEventHandler(wxEvtHandler* handler);
+ /**
+ wxWindows cannot be used to form event handler chains; this function
+ thus will assert when called.
+
+ Note that instead you can use PushEventHandler() or SetEventHandler() to
+ implement a stack of event handlers to override wxWindow's own
+ event handling mechanism.
+ */
+ virtual void SetNextHandler(wxEvtHandler* handler);
+
+ /**
+ wxWindows cannot be used to form event handler chains; this function
+ thus will assert when called.
+
+ Note that instead you can use PushEventHandler() or SetEventHandler() to
+ implement a stack of event handlers to override wxWindow's own
+ event handling mechanism.
+ */
+ virtual void SetPreviousHandler(wxEvtHandler* handler);
+
//@}
+
/**
@name Window styles functions
*/
explanations of when you might want to do it.
*/
void SendDestroyEvent();
+
+ //@{
+ /**
+ This function is public in wxEvtHandler but is protected in wxWindow because
+ for wxWindows you should always use this function on the pointer returned
+ by GetEventHandler() and not on the wxWindow object itself.
+
+ Note that it's still possible to call these functions directly on the
+ wxWindow object (e.g. downcasting it to wxEvtHandler) but doing that
+ will create subtle bugs when windows with event handlers pushed on them
+ are involved.
+ */
+ virtual bool ProcessEvent(wxEvent& event);
+ bool SafelyProcessEvent(wxEvent& event);
+ virtual void QueueEvent(wxEvent *event);
+ virtual void AddPendingEvent(const wxEvent& event);
+ void ProcessPendingEvents();
+ bool ProcessThreadEvent(const wxEvent& event);
+ //@}
};