@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
-
-
-<hr>
-
-
-@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
event), checking the event source object or its id allows to distinguish
between them.
+@see wxEvtHandler, wxWindow, wxEvent
+
+
@section overview_events_eventhandling Event Handling
// obligation to do that; this one is an event handler too:
void DoTest(wxCommandEvent& event);
- DECLARE_EVENT_TABLE()
+ wxDECLARE_EVENT_TABLE()
};
@endcode
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:
MyFrame::MyFrame()
{
- Bind( wxEVT_COMMAND_MENU_SELECTED, &myFunctor, wxID_EXIT );
+ Bind( wxEVT_COMMAND_MENU_SELECTED, myFunctor, wxID_EXIT );
}
@endcode
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<>():
event.SetEventObject(this);
// Give it some contents
- event.SetText("Hello");
+ event.SetString("Hello");
// Do send it
ProcessWindowEvent(event);
// 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()
{
-@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".
*/
-