File: port4.htm

package info (click to toggle)
wxwin2-doc 2.01-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,540 kB
  • ctags: 5,968
  • sloc: cpp: 15,157; makefile: 434; sh: 6
file content (28 lines) | stat: -rw-r--r-- 1,630 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<HTML>
<head><title>Callbacks</title></head>

<BODY BGCOLOR=#FFFFFF>
<A NAME="topic0"></A><CENTER>
<A HREF="port.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="port3.htm#eventsystem"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="port3.htm#eventsystem"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="port5.htm#topic1"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>

<H2>Callbacks</H2>
<P>
Instead of callbacks for panel items, menu command events, control commands and other events are directed to
the originating window, or an ancestor, or an event handler that has been plugged into the window
or its ancestor. Event handlers always have one argument, a derivative of wxEvent.<P>
For menubar commands, the <B>OnMenuCommand</B> member function will be replaced by a series of separate member functions,
each of which responds to a particular command. You need to add these (non-virtual) functions to your
frame class, add a DECLARE_EVENT_TABLE entry to the class, and then add an event table to
your implementation file, as a BEGIN_EVENT_TABLE and END_EVENT_TABLE block. The
individual event mapping macros will be of the form:<P>
<PRE>
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_MENU(MYAPP_NEW, MyFrame::OnNew)
    EVT_MENU(wxID_EXIT, MyFrame::OnExit)
END_EVENT_TABLE()
</PRE>
Control commands, such as button commands, can be routed to a derived button class,
the parent window, or even the frame. Here, you use a function of the form EVT_BUTTON(id, func).
Similar macros exist for other control commands.<P>

</BODY></HTML>