Mercurial > emacs
comparison src/macmenu.c @ 62988:3ca414a25103
* macmenu.c (cleanup_popup_menu): New function.
(Fx_popup_menu): unwind protect cleanup_popup_menu in case
mac_menu_show Quit:s.
(mac_menu_show): Quit on cancel if not popped up on click (i.e.
a dialog).
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Sat, 04 Jun 2005 08:06:57 +0000 |
parents | 5ba03d610746 |
children | a817e29f8ce0 01137c1fdbe9 |
comparison
equal
deleted
inserted
replaced
62987:5378f1ac43f4 | 62988:3ca414a25103 |
---|---|
600 push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil, Qnil, Qnil, Qnil); | 600 push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil, Qnil, Qnil, Qnil); |
601 } | 601 } |
602 } | 602 } |
603 } | 603 } |
604 | 604 |
605 static Lisp_Object | |
606 cleanup_popup_menu (arg) | |
607 Lisp_Object arg; | |
608 { | |
609 discard_menu_items (); | |
610 } | |
611 | |
605 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, | 612 DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, |
606 doc: /* Pop up a deck-of-cards menu and return user's selection. | 613 doc: /* Pop up a deck-of-cards menu and return user's selection. |
607 POSITION is a position specification. This is either a mouse button | 614 POSITION is a position specification. This is either a mouse button |
608 event or a list ((XOFFSET YOFFSET) WINDOW) where XOFFSET and YOFFSET | 615 event or a list ((XOFFSET YOFFSET) WINDOW) where XOFFSET and YOFFSET |
609 are positions in pixels from the top left corner of WINDOW's frame | 616 are positions in pixels from the top left corner of WINDOW's frame |
645 FRAME_PTR f = NULL; | 652 FRAME_PTR f = NULL; |
646 Lisp_Object x, y, window; | 653 Lisp_Object x, y, window; |
647 int keymaps = 0; | 654 int keymaps = 0; |
648 int for_click = 0; | 655 int for_click = 0; |
649 struct gcpro gcpro1; | 656 struct gcpro gcpro1; |
657 int specpdl_count = SPECPDL_INDEX (); | |
658 | |
650 | 659 |
651 #ifdef HAVE_MENUS | 660 #ifdef HAVE_MENUS |
652 if (! NILP (position)) | 661 if (! NILP (position)) |
653 { | 662 { |
654 check_mac (); | 663 check_mac (); |
804 return Qnil; | 813 return Qnil; |
805 } | 814 } |
806 | 815 |
807 #ifdef HAVE_MENUS | 816 #ifdef HAVE_MENUS |
808 /* Display them in a menu. */ | 817 /* Display them in a menu. */ |
818 record_unwind_protect (cleanup_popup_menu, Qnil); | |
809 BLOCK_INPUT; | 819 BLOCK_INPUT; |
810 | 820 |
811 selection = mac_menu_show (f, xpos, ypos, for_click, | 821 selection = mac_menu_show (f, xpos, ypos, for_click, |
812 keymaps, title, &error_name); | 822 keymaps, title, &error_name); |
813 UNBLOCK_INPUT; | 823 UNBLOCK_INPUT; |
814 | 824 unbind_to (specpdl_count, Qnil); |
815 discard_menu_items (); | |
816 | 825 |
817 UNGCPRO; | 826 UNGCPRO; |
818 #endif /* HAVE_MENUS */ | 827 #endif /* HAVE_MENUS */ |
819 | 828 |
820 if (error_name) error (error_name); | 829 if (error_name) error (error_name); |
1929 } | 1938 } |
1930 i += MENU_ITEMS_ITEM_LENGTH; | 1939 i += MENU_ITEMS_ITEM_LENGTH; |
1931 } | 1940 } |
1932 } | 1941 } |
1933 } | 1942 } |
1943 else if (!for_click) | |
1944 /* Make "Cancel" equivalent to C-g. */ | |
1945 Fsignal (Qquit, Qnil); | |
1934 | 1946 |
1935 return Qnil; | 1947 return Qnil; |
1936 } | 1948 } |
1937 | 1949 |
1938 | 1950 |