Welcome, Guest. Please login or register.

Author Topic: C - Menus and multiple selections...  (Read 21547 times)

Description:

0 Members and 2 Guests are viewing this topic.

Offline Joloo

Re: C - Menus and multiple selections...
« on: April 11, 2023, 05:56:22 PM »
Hi,

you have to read the mask "NextSelect" after having processed the current item.
For menu items that mutually exclude each other and when you bypass Intuition, i.e. no mouse button involved, you'll have to set them manually.

Pseudo code for processing menu items:

Code: [Select]
struct Window *wdhnd /*, *intuiwin */;
struct Message *msg;
ULONG intuiclass, itemid;
UWORD intuicode;
void *intuiaddr;
struct Menu *menu;
struct MenuItem *item;

while ( (msg = GetMsg( wdhnd->UserPort )) )
{
  intuiclass = (ULONG) ((struct IntuiMessage *) msg)->Class;
  intuicode = ((struct IntuiMessage *) msg)->Code;
  intuiaddr = ((struct IntuiMessage *) msg)->IAddress;
  /* intuiwin = ((struct IntuiMessage *) msg)->IDCMPWindow; */

  switch (intuiclass)
  {
    case IDCMP_MENUPICK:
      /* The old Intuition (OS1.2, OS1.3)
         require Forbid-state while modifying
         this Intuition field */
      Forbid();
      wdhnd->Flags |= WFLG_RMBTRAP;
      Permit();

      /* Process _ALL_ menu actions... */
      while (1)
      {
        if (intuicode == MENUNULL || intuicode == 0)
          break;
        item = ItemAddress( menu, intuicode);
        if (item)
        {
          .... do your thing here ...

          /* Start processing next selected menu item but
             watch out if the window was closed; without
             any safety query, an Enforcer Hit isn't very far */
          /* Insert here a check if the window is still open */

          ... your check here ...

          /* Set intuicode to zero if your window was shut down,
             then break, otherwise continue with processing menu items: */

          intuicode = item->NextSelect;
        }
        else
        {
          intuicode = 0;
        }
      }

      Forbid();
      wdhnd->Flags &= ~WFLG_RMBTRAP;
      Permit();

      break;

    case IDCMP_DISKINSERTED:
    case IDCMP_DISKREMOVED:
      break;
  }
  ....
}

Kind regards