Table of Contents

wxMenuItem

include file: wxMenu


wxMenuItems must have a wxMenu parent.

Parameters for creating a new menuitem:

To create a submenu, you first need to create a wxMenu with no parent, and pass the result in the subMenu parameter.

To set up event handlers for menus, use the wxEVT_COMMAND_MENU_SELECTED event type. Also, you should use the main frame, or some other control that is derived from wxWindow or wxEvtHandler, since the menu classes do not have their own event handlers. Under Linux, it is also required that you pass both the object which will act as the wxEvtHandler, and the parent menu of the wxMenuItem (Windows will work without this, but it's recommended that you always pass both the wxEvtHandler and the wxMenu for cross platform compatibility).

ex:

procedure on_open_menu( atom this, atom event ) -- do stuff end procedure

-- if you used a specific wxID_ constant when you created the wxMenuItem, you could -- use that instead of get_menuitem_id: wxID_OPEN, wxID_NEW, etc

set_event_handler( {main, the_open_menu_parent}, get_menuitem_id( the_open_menu ), wxEVT_COMMAND_MENU_SELECTED, routine_id("on_open_menu"))

 
 
Parent Topics:
  • Classes
  • Menus