Author Topic: Writing code to handle a click on a menu item  (Read 3013 times)

Offline Grouch

  • Multiple posting newcomer
  • *
  • Posts: 40
Writing code to handle a click on a menu item
« on: April 20, 2010, 05:57:45 am »
Making and coding menus in wxSmith does not seem to be covered in the tutorials on the wxSmith website, but following a hint by Jens in this forum, I found that wxSmith actually has a nice editor for creating menus.  You bring it up by double clicking on the leftmost square icon in the panel just above the editor window.  But once the menu is created, does wxSmith offer any help in writing the response to a click on a menu item?  In Borland C++ Builder, for example, a double click on the menu item in the menu editor would take you to the point in the code where the frame had been created for writing the code to respond to a click on the item.  You had then only to fill in what went between the { and the } brace. I have not been able to find a corresponding feature in wxSmith.  Am I missing something?

Thanks for any help.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Writing code to handle a click on a menu item
« Reply #1 on: April 20, 2010, 01:35:00 pm »
Open the wxs-file (if not already opened), go to the Management pane and switch to the resources tab.
In the tree open the wxMenubar and find the menuentry you want to change, highlight it and in the window below (where you can change the resources options click on the two braces ("{}").
If the menu-entry is new, you should have "EVT_MENU" on the left side and "--None--" on the right, highlight the line and you can chose between using an already existing event-handler (if any) or creating a new one.

Offline Grouch

  • Multiple posting newcomer
  • *
  • Posts: 40
Re: Writing code to handle a click on a menu item
« Reply #2 on: April 23, 2010, 06:33:53 am »
Thanks, Jens, for this clear and complete explanation. It worked.  I had gotten down to the last line, but it had not occurred to me to highlight the line.

Because creation of menus was not well covered in the tutorials, I have written one for my own benefit and that of friends and co-workers whom I want to interest in Code::Blocks.  Is there a way to contribute it to the broader community?  Would you be willing to take a look at it before I spread errors?