From: Po Lu Date: Tue, 3 May 2022 08:12:24 +0000 (+0800) Subject: Make menu bar help text work on macOS as well X-Git-Tag: emacs-29.0.90~1931^2~113 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5adc84a27b86cdbd048ee3ebc023549c928f7425;p=emacs.git Make menu bar help text work on macOS as well * lisp/tooltip.el (tooltip-show-help): Resort to displaying messages in the echo area on NS. * src/nsmenu.m ([EmacsMenu menu:willHighlightItem:]): Call `show_help_echo' instead of storing an event into the keyboard buffer. --- diff --git a/lisp/tooltip.el b/lisp/tooltip.el index 0ee3c38e26d..d6b6b1bc9b0 100644 --- a/lisp/tooltip.el +++ b/lisp/tooltip.el @@ -377,7 +377,11 @@ It is also called if Tooltip mode is on, for text-only displays." (defun tooltip-show-help (msg) "Function installed as `show-help-function'. MSG is either a help string to display, or nil to cancel the display." - (if (and (display-graphic-p)) + (if (and (display-graphic-p) + ;; Tooltips can't be displayed on top of the global menu + ;; bar on NS. + (or (not (eq window-system 'ns)) + (menu-or-popup-active-p))) (let ((previous-help tooltip-help-message)) (setq tooltip-help-message msg) (cond ((null msg) diff --git a/src/nsmenu.m b/src/nsmenu.m index 0f7d1fb98f6..b0ab12bb87d 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -760,12 +760,6 @@ prettify_key (const char *key) : Qnil; } -#ifdef NS_IMPL_GNUSTEP -/* The code below doesn't work on Mac OS X, because it runs a nested - Carbon-related event loop to track menu bar movement. - - But it works fine aside from that, so it will work on GNUstep if - they start to call `willHighlightItem'. */ - (void) menu: (NSMenu *) menu willHighlightItem: (NSMenuItem *) item { NSInteger idx = [item tag]; @@ -779,12 +773,11 @@ prettify_key (const char *key) XSETFRAME (frame, f); help = AREF (vec, idx + MENU_ITEMS_ITEM_HELP); + popup_activated_flag++; if (STRINGP (help) || NILP (help)) - kbd_buffer_store_help_event (frame, help); - - raise (SIGIO); + show_help_echo (help, Qnil, Qnil, Qnil); + popup_activated_flag--; } -#endif #ifdef NS_IMPL_GNUSTEP - (void) close