Processing Menu Events

From WxWiki
Jump to: navigation, search

Now that there are menus on the frame, there needs to be a way to implement actions when the user selects a menu. Each selection of a menu generates an event. How is it possible to attach an action to this event? The trick is that you attach a method of your class to the event. In this chapter, only the events generated by menus are explained. The details about event handling are discussed in the Events section.

Each class that processes events needs to declare an event table. The DECLARE_EVENT_TABLE macro is used for this. For each event a method must be implemented. Each method has one argument which contains information of the event. An event received from a menu is a wxCommandEvent. Look at The Full Implementation Of The TextFrame Class.