X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/eb23d11e000642b1e2a455df072db4e3783077aa..4e15d1caa03346c126015019c1fdf093033ef40b:/docs/doxygen/overviews/eventhandling.h
diff --git a/docs/doxygen/overviews/eventhandling.h b/docs/doxygen/overviews/eventhandling.h
index 0c78592351..405b3e1f36 100644
--- a/docs/doxygen/overviews/eventhandling.h
+++ b/docs/doxygen/overviews/eventhandling.h
@@ -3,26 +3,14 @@
// Purpose: topic overview
// Author: wxWidgets team
// RCS-ID: $Id$
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@page overview_events Events and Event Handling
-Related classes: wxEvtHandler, wxWindow, wxEvent
-
-@li @ref overview_events_introduction
-@li @ref overview_events_eventhandling
-@li @ref overview_events_processing
-@li @ref overview_events_custom
-@li @ref overview_events_misc
-
-
-
-
-
-@section overview_events_introduction Introduction to Events
+@tableofcontents
Like with all the other GUI frameworks, the control of flow in wxWidgets
applications is event-based: the program normally performs most of its actions
@@ -57,6 +45,9 @@ To be more precise, each event is described by:
event), checking the event source object or its id allows to distinguish
between them.
+@see wxEvtHandler, wxWindow, wxEvent
+
+
@section overview_events_eventhandling Event Handling
@@ -110,7 +101,7 @@ return information is passed via the argument, which is why it is non-const).
You also need to insert a macro
@code
-DECLARE_EVENT_TABLE()
+wxDECLARE_EVENT_TABLE()
@endcode
somewhere in the class declaration. It doesn't matter where it appears but
@@ -141,7 +132,7 @@ private:
// obligation to do that; this one is an event handler too:
void DoTest(wxCommandEvent& event);
- DECLARE_EVENT_TABLE()
+ wxDECLARE_EVENT_TABLE()
};
@endcode
@@ -150,12 +141,12 @@ placed in an implementation file. The event table tells wxWidgets how to map
events to member functions and in our example it could look like this:
@code
-BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
EVT_MENU(DO_TEST, MyFrame::DoTest)
EVT_SIZE(MyFrame::OnSize)
EVT_BUTTON(BUTTON1, MyFrame::OnButton1)
-END_EVENT_TABLE()
+wxEND_EVENT_TABLE()
@endcode
Notice that you must mention a method you want to use for the event handling in
@@ -225,7 +216,7 @@ events.
The possibilities of handling events in this way are rather different.
Let us start by looking at the syntax: the first obvious difference is that you
-need not use DECLARE_EVENT_TABLE() nor BEGIN_EVENT_TABLE() and the
+need not use wxDECLARE_EVENT_TABLE() nor wxBEGIN_EVENT_TABLE() and the
associated macros. Instead, in any place in your code, but usually in
the code of the class defining the handler itself (and definitely not in the
global scope as with the event tables), call its Bind<>() method like this:
@@ -374,7 +365,7 @@ MyFunctor myFunctor;
MyFrame::MyFrame()
{
- Bind( wxEVT_COMMAND_MENU_SELECTED, &myFunctor, wxID_EXIT );
+ Bind( wxEVT_COMMAND_MENU_SELECTED, myFunctor, wxID_EXIT );
}
@endcode
@@ -537,7 +528,7 @@ and their parent-child relation are well understood by the programmer while it
may be difficult, if not impossible, to track down all the dialogs that
may be popped up in a complex program (remember that some are created
automatically by wxWidgets). If you need to specify a different behaviour for
-some reason, you can use wxWindow::SetExtraStyle(wxWS_EX_BLOCK_EVENTS)
+some reason, you can use wxWindow::SetExtraStyle(wxWS_EX_BLOCK_EVENTS)
explicitly to prevent the events from being propagated beyond the given window
or unset this flag for the dialogs that have it on by default.
@@ -594,6 +585,16 @@ Both strategies are described in details below. See also the @ref
page_samples_event for a complete example of code defining and working with the
custom event types.
+Finally, you will need to generate and post your custom events.
+Generation is as simple as instancing your custom event class and initializing
+its internal fields.
+For posting events to a certain event handler there are two possibilities:
+using wxEvtHandler::AddPendingEvent or using wxEvtHandler::QueueEvent.
+Basically you will need to use the latter when doing inter-thread communication;
+when you use only the main thread you can also safely use the former.
+Last, note that there are also two simple global wrapper functions associated
+to the two wxEvtHandler mentioned functions: wxPostEvent() and wxQueueEvent().
+
@subsection overview_events_custom_existing Using Existing Event Classes
@@ -611,16 +612,16 @@ wxDECLARE_EVENT(MY_EVENT, wxCommandEvent);
wxDEFINE_EVENT(MY_EVENT, wxCommandEvent);
// example of code handling the event with event tables
-BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU (wxID_EXIT, MyFrame::OnExit)
...
EVT_COMMAND (ID_MY_WINDOW, MY_EVENT, MyFrame::OnMyEvent)
-END_EVENT_TABLE()
+wxEND_EVENT_TABLE()
void MyFrame::OnMyEvent(wxCommandEvent& event)
{
// do something
- wxString text = event.GetText();
+ wxString text = event.GetString();
}
// example of code handling the event with Bind<>():
@@ -636,7 +637,7 @@ void MyWindow::SendEvent()
event.SetEventObject(this);
// Give it some contents
- event.SetText("Hello");
+ event.SetString("Hello");
// Do send it
ProcessWindowEvent(event);
@@ -701,9 +702,9 @@ typedef void (wxEvtHandler::*MyPlotEventFunction)(MyPlotEvent&);
// example of code handling the event (you will use one of these methods, not
// both, of course):
-BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_PLOT(ID_MY_WINDOW, MyFrame::OnPlot)
-END_EVENT_TABLE()
+wxEND_EVENT_TABLE()
MyFrame::MyFrame()
{
@@ -862,11 +863,10 @@ your identifiers don't conflict accidentally.
-@subsection overview_events_list List of wxWidgets events
+@subsection overview_events_list List of wxWidgets Events
For the full list of event classes, please see the
@ref group_class_events "event classes group page".
*/
-