GNOME Bugzilla – Bug 101309
No-alt for menubar accelerators during navigation
Last modified: 2011-02-04 16:17:18 UTC
Right now, if you hit F10 to go the menubar, you still need to hit Alt-letter to access the mnemonics on the menubar. Fixing this is rather difficult because the mnemonics on the menubar need to be used in two contexts: A) With the alt-key and conflict resolved with all other accelerators on the toplevel normally B) Without the alt-key and conflict resolved only with the menubar accelerators during navigation. The attached patch handles this by separating the mnemonic resolution parts of GtkWindow into a separate GtkMnemonicHash object, and making GtkMenuShell maintain it's own MnemonicHash that is used during navigation. One could also take the MnemonicHash idea in a different direction and dynamically construct a MnemonicHash on keypress during navigation and use that to resolve conflicts between the mnemonics on _all_ visible menus. That might be a little slow. (The function you'd need there is gtk_mnemonic_hash_merge() to construct a composite mnemonic hash.) An completely different approach to go would be to not split mnemonic hashes out at all, but to have a GtkWindow function like _gtk_window_activate_key() that only activated mnemonics in a single portion of the widget heirarchy; going that way: a) Key resolution wouldn't be restricted to the the menu bar accelerators. (But if Alt-<key> worked with the menu not popped up, then <key> would work during navigation.) b) There would be no natural extension to conflict resolution between accelerators on multiple menus. But it probably would be a lot simpler.
Created attachment 13009 [details] [review] Patch adding and using GtkMnemonicHash
Downsides of the attached patch are: - It's a bit large (around 300 new lines of code) - It breaks putting GtkLabel cut-and-paste widgets with mnemonic widgets into a menu since GtkLabel now has to do something different when inside a GtkMenuShell.
Apologies for spam-- ensuring Sun a11y team are cc'ed on all current a11y bugs. Filter on "SUN A11Y SPAM" to ignore.
Created attachment 34664 [details] [review] update Here is an update which works against current cvs HEAD
Would be very nice to have this. Thanks Matthias! It is kind of a big patch, but it will help keyboard-only and blind users a lot.
It only works once, though. Ie you can F10 to the menubar (and leave the focus on the menubar), then use e.g E to go to the edit menu, but after that, the focus is inside the edit menu, so pressing F doesn't bring you back to the file menu, but activates whatever item has F as mnemonic inside the edit menu.
2004-12-10 Matthias Clasen <mclasen@redhat.com> Support no-Alt mnemnonics in menu bars (#101309, Owen Taylor) * gtk/gtkwindow.c: Factor out mnemonic hash code into a separate file. * gtk/gtkmnemonichash.[hc]: Factored out mnemonic hash code from gtkwindow.c. * gtk/Makefile.am (gtk_c_sources): Add gtkmnemonichash.[hc]. * gtk/gtkmenushell.c (struct _GtkMenuShellPrivate): Give menu shells their own mnemonic hash. * gtk/gtkmenushell.h: Add private api to support mnemonics. * gtk/gtklabel.c (gtk_label_setup_mnemonic): Add mnemonic to the menushell mnemonic hash when inside a menu.
Matthias, I think there's a copy'n'paste error in gtk_label_setup_mnemonic: if (label->mnemonic_window) { gtk_window_remove_mnemonic (label->mnemonic_window, last_key, widget); label->mnemonic_window = NULL; } if (mnemonic_menu) { _gtk_menu_shell_remove_mnemonic (GTK_MENU_SHELL (mnemonic_menu), last_key, widget); label->mnemonic_window = NULL; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ HERE Shouldn't it set mnemonic_menu = NULL or something instead? I tried running latest gtk+ from CVS with GIMP 2.0.6 (on WinXP), and get the following assertion which I think is caused by the above. (gimp-2.0.exe): Gtk-CRITICAL **: _gtk_mnemonic_hash_remove: assertion `targets && g_slist_find (targets, target) != NULL' failed
+ Trace 53437
I think you are correct. Does this fix it for you ? 2004-12-12 Matthias Clasen <mclasen@redhat.com> * gtk/gtklabel.c (gtk_label_setup_mnemonic): Fix a copy-and-paste error, noticed by Robert Ögren.
Matthias, yes that fixed it. Thanks.