>>>>> On Sat, 4 Jun 2005 09:04:02 +0200, jhd <[EMAIL PROTECTED]> 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
                                [EMAIL PROTECTED]

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);
}


_______________________________________________
Emacs-pretest-bug mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug

Reply via email to