bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#5871: [Aquamacs-bugs] Re: yes-or-no-p menu


From: YAMAMOTO Mitsuharu
Subject: bug#5871: [Aquamacs-bugs] Re: yes-or-no-p menu
Date: Thu, 08 Apr 2010 16:59:52 -0000
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/22.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Sat, 4 Jun 2005 09:04:02 +0200, jhd <address@hidden> said:

> But I would also like C-g to do a quit as it does on X11, but I
> could not find a way to make PopUpMenuSelect return and pop down the
> menu form within an event handler function.  Anybody knows how to do
> that?

Installing a Carbon Event handler on a menu seems to work, but only
for Mac OS X 10.3 and later because CancelMenuTracking is not
available on earlier versions.

                                     YAMAMOTO Mitsuharu
                                address@hidden

static pascal OSStatus
mac_handle_menu_event (next_handler, event, data)
     EventHandlerCallRef next_handler;
     EventRef event;
     void *data;
{
  MenuRef menu = data;

  switch (GetEventKind (event))
    {
    case kEventRawKeyDown:
      {
        char c;

        GetEventParameter (event, kEventParamKeyMacCharCodes, typeChar,
                           NULL, sizeof (char), NULL, &c);
        if (c == 7)             /* C-g */
          {
            CancelMenuTracking (menu, true, 0);

            return noErr;
          }
        else
          return CallNextEventHandler (next_handler, event);
      }
      break;

    default:
      break;
    }

  return eventNotHandledErr;
}

static OSErr
install_menu_handler (menu)
     MenuRef menu;
{
  EventTypeSpec specs[] = {{kEventClassKeyboard, kEventRawKeyDown}};

  return InstallMenuEventHandler (menu, mac_handle_menu_event,
                                  GetEventTypeCount (specs), specs,
                                  menu, NULL);
}








reply via email to

[Prev in Thread] Current Thread [Next in Thread]