Menu Manager Toolset - NewMenu

Purpose: Allocate space for a menu list and items

C usage:

#include <Menu.h>

MenuRecHndl NewMenu(const char* menuString);

Original documentation
Apple IIGS Toolbox Reference, Volume 1, p. 13-7 to 13-14 Apple Programmer’s Workshop <Menu.h> Mark Andrews, Programming the Apple IIGS, pp. 292-293

Minimal example

#define FILE_MENU 256
#define QUIT_ITEM 257
static const char[] menuString = ">>File\\N256\r--Quit\\N257\r;";

MenuRecHndl menu = NewMenu(menuString);
InsertMenu(menu, 0);
FixMenuBar();
DrawMenuBar();

Notes

  1. Menu and item IDs need to be 256 or higher, or they conflict with system IDs.
  2. The format of the menuString is detailed in Apple IIGS Toolbox Reference Volume 1, from 13-13 to 13-15. The carriage returns (\r) are how the Menu Manager separates lines in the string.
  3. Apple warns that menu IDs must be unique for each menu, or the system will fail. Menu item IDs must also be unique. (page 13-16)
  4. Menus require starting the menu manager (MenuStartUp()), and shutting the menu manager down on application exit (MenuShutDown()) to reclaim menu resources.
    In ORCA/C, the call to MenuStartUp() and MenuShutDown() are handled by startdesk() and enddesk(), respectively.
    They are not shown here.