diff options
author | Adrian Robert <Adrian.B.Robert@gmail.com> | 2008-08-04 16:57:44 +0000 |
---|---|---|
committer | Adrian Robert <Adrian.B.Robert@gmail.com> | 2008-08-04 16:57:44 +0000 |
commit | 07b87a106a72dc6647dbe5910c78506c576f5399 (patch) | |
tree | 957ced55f63c30149b269ae1d4f8b8429eea23cb /src/nsmenu.m | |
parent | 14145fa3d03d61fec15d5939b5c4417c9d6472d9 (diff) | |
download | emacs-07b87a106a72dc6647dbe5910c78506c576f5399.tar.gz |
fix popup menu selection return (menu.c); add use of popup_activated under NS (nsmenu.m, xdisp.c); improve comments (lisp.h, s/darwin.h); use FORWARD_SIGNAL_TO_MAIN_THREAD (syssignal.h)
Diffstat (limited to 'src/nsmenu.m')
-rw-r--r-- | src/nsmenu.m | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/nsmenu.m b/src/nsmenu.m index 822aa94efa9..b4e8dbc9143 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -65,6 +65,9 @@ extern Lisp_Object Voverriding_local_map, Voverriding_local_map_menu_flag, extern long context_menu_value; EmacsMenu *mainMenu, *svcsMenu; +/* Nonzero means a menu is currently active. */ +static int popup_activated_flag; + /* NOTE: toolbar implementation is at end, following complete menu implementation. */ @@ -94,6 +97,13 @@ free_frame_menubar (struct frame *f) } +int +popup_activated () +{ + return popup_activated_flag; +} + + /* -------------------------------------------------------------------------- Update menubar. Three cases: 1) deep_p = 0, submenu = nil: Fresh switch onto a frame -- either set up @@ -592,6 +602,7 @@ name_is_separator (name) return [NSString stringWithFormat: @"%c", tpos[2]]; } + - (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr { NSMenuItem *item; @@ -1117,10 +1128,13 @@ ns_popup_menu (Lisp_Object position, Lisp_Object menu) free_menubar_widget_value_tree (first_wv); unbind_to (specpdl_count2, Qnil); + popup_activated_flag = 1; tem = [pmenu runMenuAt: p forFrame: f keymaps: keymaps]; + popup_activated_flag = 0; [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; UNBLOCK_INPUT; + discard_menu_items (); unbind_to (specpdl_count, Qnil); UNGCPRO; @@ -1511,8 +1525,9 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2; dialog = [[EmacsDialogPanel alloc] initFromContents: contents isQuestion: isQ]; - + popup_activated_flag = 1; tem = [dialog runDialogAt: p]; + popup_activated_flag = 0; [dialog close]; @@ -1934,6 +1949,12 @@ for instance using the window manager, then this produces a quit and return ns_popup_dialog (position, contents, header); } +DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_p, 0, 0, 0, + doc: /* Return t if a menu or popup dialog is active. */) + () +{ + return popup_activated () ? Qt : Qnil; +} /* ========================================================================== @@ -1947,6 +1968,7 @@ syms_of_nsmenu () defsubr (&Sx_popup_menu); defsubr (&Sx_popup_dialog); defsubr (&Sns_reset_menu); + defsubr (&Smenu_or_popup_active_p); staticpro (&menu_items); menu_items = Qnil; |