aboutsummaryrefslogtreecommitdiffstats
path: root/src/macmenu.c
diff options
context:
space:
mode:
authorKaroly Lorentey2007-01-06 15:25:16 +0000
committerKaroly Lorentey2007-01-06 15:25:16 +0000
commit191ae1cf7cd2571277635b3b8e488e773ca5c9b9 (patch)
treee0b26e3040767dae38fb39a03b757da05088c58f /src/macmenu.c
parent382707ecfb50f8c7794a7ba3d8cd9db9b6cd29d0 (diff)
parentf85c5e3b72855951b071eacb7b6e2d002c5fc4be (diff)
downloademacs-191ae1cf7cd2571277635b3b8e488e773ca5c9b9.tar.gz
emacs-191ae1cf7cd2571277635b3b8e488e773ca5c9b9.zip
Merged from emacs@sv.gnu.org
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-585 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-586 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-587 Update from erc--emacs--22 * emacs@sv.gnu.org/emacs--devo--0--patch-588 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-589 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-590 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-591 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-592
Diffstat (limited to 'src/macmenu.c')
-rw-r--r--src/macmenu.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/macmenu.c b/src/macmenu.c
index 14bfe92cb25..9981250979a 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -1450,6 +1450,80 @@ update_submenu_strings (first_wv)
1450} 1450}
1451 1451
1452 1452
1453#if TARGET_API_MAC_CARBON
1454extern Lisp_Object Vshow_help_function;
1455
1456static Lisp_Object
1457restore_show_help_function (old_show_help_function)
1458 Lisp_Object old_show_help_function;
1459{
1460 Vshow_help_function = old_show_help_function;
1461
1462 return Qnil;
1463}
1464
1465static pascal OSStatus
1466menu_target_item_handler (next_handler, event, data)
1467 EventHandlerCallRef next_handler;
1468 EventRef event;
1469 void *data;
1470{
1471 OSStatus err, result;
1472 MenuRef menu;
1473 MenuItemIndex menu_item;
1474 Lisp_Object help;
1475 GrafPtr port;
1476 int specpdl_count = SPECPDL_INDEX ();
1477
1478 result = CallNextEventHandler (next_handler, event);
1479
1480 err = GetEventParameter (event, kEventParamDirectObject, typeMenuRef,
1481 NULL, sizeof (MenuRef), NULL, &menu);
1482 if (err == noErr)
1483 err = GetEventParameter (event, kEventParamMenuItemIndex,
1484 typeMenuItemIndex, NULL,
1485 sizeof (MenuItemIndex), NULL, &menu_item);
1486 if (err == noErr)
1487 err = GetMenuItemProperty (menu, menu_item,
1488 MAC_EMACS_CREATOR_CODE, 'help',
1489 sizeof (Lisp_Object), NULL, &help);
1490 if (err != noErr)
1491 help = Qnil;
1492
1493 /* Temporarily bind Vshow_help_function to Qnil because we don't
1494 want tooltips during menu tracking. */
1495 record_unwind_protect (restore_show_help_function, Vshow_help_function);
1496 Vshow_help_function = Qnil;
1497 GetPort (&port);
1498 show_help_echo (help, Qnil, Qnil, Qnil, 1);
1499 SetPort (port);
1500 unbind_to (specpdl_count, Qnil);
1501
1502 return err == noErr ? noErr : result;
1503}
1504#endif
1505
1506OSStatus
1507install_menu_target_item_handler (window)
1508 WindowPtr window;
1509{
1510 OSStatus err = noErr;
1511#if TARGET_API_MAC_CARBON
1512 static const EventTypeSpec specs[] =
1513 {{kEventClassMenu, kEventMenuTargetItem}};
1514 static EventHandlerUPP menu_target_item_handlerUPP = NULL;
1515
1516 if (menu_target_item_handlerUPP == NULL)
1517 menu_target_item_handlerUPP =
1518 NewEventHandlerUPP (menu_target_item_handler);
1519
1520 err = InstallWindowEventHandler (window, menu_target_item_handlerUPP,
1521 GetEventTypeCount (specs), specs,
1522 NULL, NULL);
1523#endif
1524 return err;
1525}
1526
1453/* Event handler function that pops down a menu on C-g. We can only pop 1527/* Event handler function that pops down a menu on C-g. We can only pop
1454 down menus if CancelMenuTracking is present (OSX 10.3 or later). */ 1528 down menus if CancelMenuTracking is present (OSX 10.3 or later). */
1455 1529
@@ -2485,6 +2559,10 @@ add_menu_item (menu, pos, wv)
2485 EnableMenuItem (menu, pos); 2559 EnableMenuItem (menu, pos);
2486 else 2560 else
2487 DisableMenuItem (menu, pos); 2561 DisableMenuItem (menu, pos);
2562
2563 if (STRINGP (wv->help))
2564 SetMenuItemProperty (menu, pos, MAC_EMACS_CREATOR_CODE, 'help',
2565 sizeof (Lisp_Object), &wv->help);
2488#else /* ! TARGET_API_MAC_CARBON */ 2566#else /* ! TARGET_API_MAC_CARBON */
2489 item_name[sizeof (item_name) - 1] = '\0'; 2567 item_name[sizeof (item_name) - 1] = '\0';
2490 strncpy (item_name, wv->name, sizeof (item_name) - 1); 2568 strncpy (item_name, wv->name, sizeof (item_name) - 1);