[Contents] [index] [Help] [Retrace] [browse <] [Browse >]

Each activation of the menu system generates only a single event.  The
user may select none, one or many items using any of the selection
techniques described above; still, only one event is sent.

The program finds out whether or not multiple items have been chosen by
examining the field called nextselect in the menuitem structure.  the
selected items are chained together through this field.  This list is only
valid until the user next activates the menu system, as the items are
chained together through the actual MenuItem structures used in the menu
system.  If the user reselects an item, the NextSelect field of that item
will be overwritten.

In processing the menu events, the application should first take the
appropriate action for the item selected by the user, then check the
nextselect field.  if the number there is equal to the constant menunull,
there is no next selection.  However, if it is not equal to MENUNULL, the
user has selected another option after this one.  The program should
process the next item as well, by checking its NextSelect field, until it
finds a NextSelect equal to MENUNULL.

The following code fragment shows the correct way to process a menu event:

    struct IntuiMessage *msg;
    struct Menu *menuStrip;
    UWORD menuNumber;
    struct MenuItem *item;

    menuNumber = msg->Code;

    while (menuNumber != MENUNULL)
        {
        item = ItemAddress(menuStrip, menuNumber);

        /* process this item */

        menuNumber = item->NextSelect;
        }

Intuition specifies which item or sub-item was selected in the
idcmp_menupick event by using a shorthand code known as a menu number.
Programs can locate the menuitem structure that corresponds to a given
menu number by using the itemaddress() function.  this function translates
a menu number into a pointer to the MenuItem structure represented by the
menu number.

    struct MenuItem *ItemAddress( struct Menu *menuStrip,
                                  unsigned long menuNumber );

This allows the application to gain access to the menuitem structure and
to correctly process multi-select events.  Again, when the user performs
multiple selection, the program will receive only one message of class
idcmp_menupick.  for the program to behave correctly, it must pay
attention to the nextselect field of the menuitem, which will lead to the
other menu selections.

There may be some cases in an application's logical flow where the
selection of a menu item voids any further menu processing.  For instance,
after processing a "quit" menu selection, the application will, in
general, ignore all further menu selections.