From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Subject: Re: UI issue: inactive menu entries and icons
Date: Sat, 30 Dec 2006 15:49:14 +0900 [thread overview]
Message-ID: <wlpsa1515h.wl%mituharu@math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <4592AC67.8060507@swipnet.se>
>>>>> On Wed, 27 Dec 2006 18:24:55 +0100, Jan Djärv <jan.h.d@swipnet.se> said:
> I agree, but it is very hard (impossible?) to do in some toolkits.
> For example, inactive usually means that no events whatsoever are
> generated for those icons/buttons. Things like Enter and Leave
> events that are used to determine what tooltip to show.
This reminds me that help echo strings for menu items are not
shown in any fashion on Mac Carbon. As showing tooltip looks
really weird (and requires not-too-small change, I guess) on this
environment, they are shown in the echo area regardless of the
value of show-help-function by the patch below. Fortunately,
targeting an inactive menu item also generates some event.
If there's no problem with this, I'll install it later (not now,
because I'm out of my usual development environment).
YAMAMOTO Mitsuharu
mituharu@math.s.chiba-u.ac.jp
Index: src/macmenu.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macmenu.c,v
retrieving revision 1.48
diff -c -p -r1.48 macmenu.c
*** src/macmenu.c 14 Nov 2006 08:22:04 -0000 1.48
--- src/macmenu.c 30 Dec 2006 06:32:10 -0000
*************** update_submenu_strings (first_wv)
*** 1450,1455 ****
--- 1450,1535 ----
}
\f
+ #if TARGET_API_MAC_CARBON
+ extern Lisp_Object Vshow_help_function;
+
+ static Lisp_Object
+ restore_show_help_function (old_show_help_function)
+ Lisp_Object old_show_help_function;
+ {
+ Vshow_help_function = old_show_help_function;
+
+ return Qnil;
+ }
+
+ static pascal OSStatus
+ menu_target_item_handler (next_handler, event, data)
+ EventHandlerCallRef next_handler;
+ EventRef event;
+ void *data;
+ {
+ OSStatus err, result;
+ MenuRef menu;
+ MenuItemIndex menu_item;
+ Lisp_Object help;
+ #ifdef MAC_OS8
+ GrafPtr port;
+ #endif
+ int specpdl_count = SPECPDL_INDEX ();
+
+ result = CallNextEventHandler (next_handler, event);
+
+ err = GetEventParameter (event, kEventParamDirectObject, typeMenuRef,
+ NULL, sizeof (MenuRef), NULL, &menu);
+ if (err == noErr)
+ err = GetEventParameter (event, kEventParamMenuItemIndex,
+ typeMenuItemIndex, NULL,
+ sizeof (MenuItemIndex), NULL, &menu_item);
+ if (err == noErr)
+ err = GetMenuItemProperty (menu, menu_item,
+ MAC_EMACS_CREATOR_CODE, 'help',
+ sizeof (Lisp_Object), NULL, &help);
+ if (err != noErr)
+ help = Qnil;
+
+ /* Temporarily bind Vshow_help_function to Qnil because we don't
+ want tooltips during menu tracking. */
+ record_unwind_protect (restore_show_help_function, Vshow_help_function);
+ Vshow_help_function = Qnil;
+ #ifdef MAC_OS8
+ GetPort (&port);
+ #endif
+ show_help_echo (help, Qnil, Qnil, Qnil, 1);
+ #ifdef MAC_OS8
+ SetPort (port);
+ #endif
+ unbind_to (specpdl_count, Qnil);
+
+ return err == noErr ? noErr : result;
+ }
+ #endif
+
+ OSStatus
+ install_menu_target_item_handler (window)
+ WindowPtr window;
+ {
+ OSStatus err = noErr;
+ #if TARGET_API_MAC_CARBON
+ static const EventTypeSpec specs[] =
+ {{kEventClassMenu, kEventMenuTargetItem}};
+ static EventHandlerUPP menu_target_item_handlerUPP = NULL;
+
+ if (menu_target_item_handlerUPP == NULL)
+ menu_target_item_handlerUPP =
+ NewEventHandlerUPP (menu_target_item_handler);
+
+ err = InstallWindowEventHandler (window, menu_target_item_handlerUPP,
+ GetEventTypeCount (specs), specs,
+ NULL, NULL);
+ #endif
+ return err;
+ }
+
/* Event handler function that pops down a menu on C-g. We can only pop
down menus if CancelMenuTracking is present (OSX 10.3 or later). */
*************** add_menu_item (menu, pos, wv)
*** 2485,2490 ****
--- 2565,2574 ----
EnableMenuItem (menu, pos);
else
DisableMenuItem (menu, pos);
+
+ if (STRINGP (wv->help))
+ SetMenuItemProperty (menu, pos, MAC_EMACS_CREATOR_CODE, 'help',
+ sizeof (Lisp_Object), &wv->help);
#else /* ! TARGET_API_MAC_CARBON */
item_name[sizeof (item_name) - 1] = '\0';
strncpy (item_name, wv->name, sizeof (item_name) - 1);
Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.199
diff -c -p -r1.199 macterm.c
*** src/macterm.c 15 Dec 2006 08:05:35 -0000 1.199
--- src/macterm.c 30 Dec 2006 06:32:11 -0000
*************** void remove_drag_handler P_ ((WindowRef)
*** 8746,8751 ****
--- 8746,8755 ----
extern void init_service_handler ();
static Lisp_Object Qservice, Qpaste, Qperform;
#endif
+
+ /* Showing help echo string during menu tracking */
+ extern OSStatus install_menu_target_item_handler P_ ((WindowPtr));
+
/* Window Event Handler */
static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
EventRef, void *);
*************** install_window_handler (window)
*** 10168,10173 ****
--- 10172,10179 ----
#endif
if (err == noErr)
err = install_drag_handler (window);
+ if (err == noErr)
+ err = install_menu_target_item_handler (window);
return err;
}
Index: src/macterm.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.h,v
retrieving revision 1.50
diff -c -p -r1.50 macterm.h
*** src/macterm.h 15 Dec 2006 08:05:42 -0000 1.50
--- src/macterm.h 30 Dec 2006 06:32:11 -0000
*************** struct scroll_bar {
*** 531,536 ****
--- 531,541 ----
#define HOURGLASS_HEIGHT 16
/* Some constants that are used locally. */
+ /* Creator code for Emacs on Mac OS. */
+ enum {
+ MAC_EMACS_CREATOR_CODE = 'EMAx'
+ };
+
/* Apple event descriptor types */
enum {
TYPE_FILE_NAME = 'fNam'
next prev parent reply other threads:[~2006-12-30 6:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-27 12:34 UI issue: inactive menu entries and icons David Kastrup
2006-12-27 15:22 ` Drew Adams
2006-12-27 16:06 ` Stefan Monnier
2006-12-27 16:19 ` David Kastrup
2006-12-27 16:47 ` Drew Adams
2006-12-27 19:17 ` David Kastrup
2006-12-28 17:19 ` Richard Stallman
2006-12-27 17:24 ` Jan Djärv
2006-12-30 6:49 ` YAMAMOTO Mitsuharu [this message]
2006-12-27 21:16 ` Richard Stallman
2006-12-29 12:12 ` Jan Djärv
2006-12-29 22:58 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=wlpsa1515h.wl%mituharu@math.s.chiba-u.ac.jp \
--to=mituharu@math.s.chiba-u.ac.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.