2.4 Add a Menu Bar

The next component we are going to add to the application is a menubar. A menubar is a common component on windows programs. Our menu bar will contain two entries, File and Help. Selecting one of these will display a dropdown menu. The user can select an option from the drop down menu.


Designer - Menu


Collection - About

Inspector - Event
  • The left hand side of the events pane shows the groups of events which are available. For the menuitem, there is only 'MenuEvent' group. Select this group using the mouse.
  • The right hand side of the events pane now shows the events in the selected group. For the menu item, there is only one event EVT_MENU in the 'MenuEvent' group. Doubleclick on this Event using the mouse.
  • The bottom of the Events pane shows the event handlers in your application for the current component (the 'About' menu item). You should now have a new handler called OnMenuHelpAboutMenu. This is the name of the method which will be invoked when the 'About' option is selected from the Help menu.
  • Notice the naming of the event handler. Boa Constructor generates the names in this manner. The event is the last part (Menu). The component is the middle part and here it is the 'About' sub-component of the 'menuHelp' component. Finally, Boa Constructor follows the convention of prefixing all event handlers with the word 'On'.
  • Close the collection Editor.

Now we must repeat the process to add options to the file menu.

Now we are going to create the menubar.


Inspector - Frame


Frame1